Advertisement
Guest User

Untitled

a guest
Sep 5th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Tuna {
  3. public static void main(String[] args) throws java.io.IOException{
  4. System.out.println("What is your name?: ");
  5. Scanner scanner = new Scanner(System.in);
  6. String studentName;
  7. studentName = scanner.nextLine();
  8. System.out.println("What is your grade?: ");
  9. char studentGrade;
  10. studentGrade = (char) System.in.read();
  11. System.out.println("How many units have you completed?: ");
  12. int studentUnits;
  13. studentUnits = scanner.nextInt();
  14. System.out.println("What is your GPA?: ");
  15. double studentGPA;
  16. studentGPA = scanner.nextDouble();
  17. System.out.println("Do you like programming?: ");
  18. String yes = "you like programming";
  19. String no = "you do not like programming";
  20. String ans = scanner.next();
  21. if (ans.equalsIgnoreCase("yes")) {
  22. System.out.print("You like programming");
  23. }
  24. else {
  25. System.out.print("You do not like programming");
  26. }
  27. 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);
  28. System.out.println("What is your name?: ");
  29. Scanner scanner2 = new Scanner(System.in);
  30. String studentName2;
  31. studentName2 = scanner2.nextLine();
  32. System.out.println("What is your grade?: ");
  33. char studentGrade2;
  34. studentGrade2 = (char) System.in.read();
  35. System.out.println("How many units have you completed?: ");
  36. int studentUnits2;
  37. studentUnits2 = scanner.nextInt();
  38. System.out.println("What is your GPA?: ");
  39. double studentGPA2;
  40. studentGPA2 = scanner2.nextDouble();
  41. System.out.println("Do you like programming?: ");
  42. boolean studentAnswer2;
  43. studentAnswer2 = scanner2.nextBoolean();
  44. if (studentAnswer2 = true)
  45. System.out.println("You like programming");
  46. else
  47. System.out.println("You do not like programming");
  48. 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);
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement