Advertisement
veronikaaa86

01. Student Information

Jan 11th, 2023
1,031
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P01StudentInformation {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String studentName = scanner.nextLine();
  8.         int age = Integer.parseInt(scanner.nextLine());
  9.         double avgGrade = Double.parseDouble(scanner.nextLine());
  10.  
  11.         //Name: John, Age: 15, Grade: 5.40
  12.  
  13.         String outputData = String.format("Name: %s, Age: %d, Grade: %.2f",
  14.                 studentName, age, avgGrade);
  15.  
  16.         System.out.println(outputData);
  17.     }
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement