Advertisement
veronikaaa86

01. Student Information

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