Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Tuna {
- public static void main(String[] args) throws java.io.IOException{
- System.out.println("What is your name?: ");
- Scanner scanner = new Scanner(System.in);
- String studentName;
- studentName = scanner.nextLine();
- System.out.println("What is your grade?: ");
- char studentGrade;
- studentGrade = (char) System.in.read();
- System.out.println("How many units have you completed?: ");
- int studentUnits;
- studentUnits = scanner.nextInt();
- System.out.println("What is your GPA?: ");
- double studentGPA;
- studentGPA = scanner.nextDouble();
- System.out.println("Do you like programming?: ");
- String yes = "you like programming";
- String no = "you do not like programming";
- String ans = scanner.next();
- if (ans.equalsIgnoreCase("yes")) {
- System.out.print("You like programming");
- }
- else {
- System.out.print("You do not like programming");
- }
- System.out.println(" Your name is: " + studentName + "\n"+ " Your grade is: "+ studentGrade + "\n" + "You have completed: " + studentUnits + " 1units "+ "\n" + " Your GPA is: " +studentGPA +"\n" + " And you: " +ans);
- System.out.println("What is your name?: ");
- Scanner scanner2 = new Scanner(System.in);
- String studentName2;
- studentName2 = scanner2.nextLine();
- System.out.println("What is your grade?: ");
- char studentGrade2;
- studentGrade2 = (char) System.in.read();
- System.out.println("How many units have you completed?: ");
- int studentUnits2;
- studentUnits2 = scanner.nextInt();
- System.out.println("What is your GPA?: ");
- double studentGPA2;
- studentGPA2 = scanner2.nextDouble();
- System.out.println("Do you like programming?: ");
- boolean studentAnswer2;
- studentAnswer2 = scanner2.nextBoolean();
- if (studentAnswer2 = true)
- System.out.println("You like programming");
- else
- System.out.println("You do not like programming");
- System.out.println(" Your name is: " + studentName2 + "\n"+ " Your grade is: "+ studentGrade2 + "\n" + "You have completed: " + studentUnits2 + "units+ "+ "\n" + " Your GPA is: " +studentGPA2 +"\n" + " And you: " +studentAnswer2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement