Basic Input and Output Operation

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/17

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:26 AM on 3/8/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

18 Terms

1
New cards
System.out.println();

Outputs the text followed by a moves to the next line.

2
New cards
System.out.print();

Outputs the text without adding a newline, meaning the next output will continue on the same line.

3
New cards
System.out.println();
System.out.print();

Output Operations

4
New cards
public class Main{
    public static void main(String[] args){
        System.out.print("wiw umaga na. ");
        System.out.println("ows taalaga ba");
        System.out.println("imissu<3");
    }
}

OUTPUT:
wiw umaga na. ows taalaga ba
imissu<3

Example of output operations

5
New cards

%d
%f
%s
%n

Common format specifiers

6
New cards

%d

Integer

7
New cards

%f

Floating point number

8
New cards

%s

String

9
New cards

%n

Newline

10
New cards
public class Main{
    public static void main(String[] args){
        
        int eyj = 19;
        double grade =  89.56;
        String misij = "unsint a misij";
        
        System.out.printf("age %d years", eyj);
        System.out.printf("grade: %.3f gew \n", grade);
        System.out.printf("misij: %s hihi %n", misij);
        System.out.print("yihi");
    }
}

OUTPUT:
age 19 yearsgrade: 89.560 gew
misij: unsint a misij hihi
yihi

Example of output operations using different format specifiers.

11
New cards

java.util package

To read input, you first need to import the Scanner class from the ________.

12
New cards
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
	Scanner scanner = new Scanner (System.in);	

}
}

Example code of the Using Scanner.

13
New cards

nextInt()
nextDouble()
nextLine()
next()

Common input methods of scanner

14
New cards

nextInt()

Reads an integer.

15
New cards

nextDouble()

Reads a double value.

16
New cards

nextLine()

Reads a string line.

17
New cards

next()

Reads a single word up to the next whitespace.

18
New cards
import java.util.Scanner;

public class Main {   

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.print("Enter your full name: ");
        String name = sc.nextLine(); 
        System.out.print("Enter your Section: ");
        String section = sc.nextLine(); 
        
        System.out.print("Enter your age: ");
        int age = sc.nextInt(); 

        System.out.print("Enter you 1st sem GWA: ");
        double gwa = sc.nextDouble(); 
	  
	System.out.println();
        System.out.println("Name: " + name);
        System.out.println("Section: " + section);
        System.out.println("Age: " + age);
        System.out.println("1st Sem General Weighted Average: " + gwa);
    }
}

OUTPUT:
Enter your full name: Jes
Enter your Section: CS12S4
Enter your age: 19
Enter you 1st sem GWA: 1.81

Name: Jes
Section: CS12S4
Age: 19
1st Sem General Weighted Average: 1.81

Example of scanner input

Explore top notes

note
Chapter 10: Membrane Structure
Updated 871d ago
0.0(0)
note
Japanese Family Vocab
Updated 122d ago
0.0(0)
note
DNA
Updated 1014d ago
0.0(0)
note
części mowy i części zdania
Updated 825d ago
0.0(0)
note
Chapter Eleven: Aggression
Updated 1126d ago
0.0(0)
note
Chapter 10: Membrane Structure
Updated 871d ago
0.0(0)
note
Japanese Family Vocab
Updated 122d ago
0.0(0)
note
DNA
Updated 1014d ago
0.0(0)
note
części mowy i części zdania
Updated 825d ago
0.0(0)
note
Chapter Eleven: Aggression
Updated 1126d ago
0.0(0)

Explore top flashcards

flashcards
Yr 10 French KO 12 ( town)
60
Updated 303d ago
0.0(0)
flashcards
Unit 2: WW|
57
Updated 466d ago
0.0(0)
flashcards
FINAL WORDPARTS QUIZ SET
62
Updated 1111d ago
0.0(0)
flashcards
Amino Acid Abbreviations
20
Updated 357d ago
0.0(0)
flashcards
Law and Admin-Chapter 6
27
Updated 470d ago
0.0(0)
flashcards
Voci 1
251
Updated 921d ago
0.0(0)
flashcards
Yr 10 French KO 12 ( town)
60
Updated 303d ago
0.0(0)
flashcards
Unit 2: WW|
57
Updated 466d ago
0.0(0)
flashcards
FINAL WORDPARTS QUIZ SET
62
Updated 1111d ago
0.0(0)
flashcards
Amino Acid Abbreviations
20
Updated 357d ago
0.0(0)
flashcards
Law and Admin-Chapter 6
27
Updated 470d ago
0.0(0)
flashcards
Voci 1
251
Updated 921d ago
0.0(0)