fork download
  1. import java.util.Scanner;
  2. /*
  3.  * Jon Nelson
  4.  * Lab 3
  5.  * CSIS 112
  6.  
  7.  Pseudocode
  8.  create 3 test variables, test1, test2, test3 to store 3 test scores
  9.  create a variable called average to store the average
  10.  Display "enter a score for test 1"
  11.  Ask test1
  12.  Display "enter a score for test 2"
  13.  Ask test2
  14.  Display "enter a score for test 3"
  15.  Ask test3
  16.  Set average equal to test1 + test2 + test3 devided by 3
  17.  Display the three test scores and the average
  18.  */
  19.  
  20. class lab3part1
  21. {
  22. public static void main(String[] args)
  23. {
  24. double test1, test2, test3, average;
  25.  
  26. Scanner keyboard = new Scanner(System.in);
  27.  
  28.  
  29. System.out.print("Enter score for Test 1: ");
  30. test1 = keyboard.nextDouble();
  31. System.out.print("Enter score for Test 2: ");
  32. test2 = keyboard.nextDouble();
  33. System.out.print("Enter score for Test 3: ");
  34. test3 = keyboard.nextDouble();
  35.  
  36. average = (test1 + test2 + test3)/3;
  37.  
  38. System.out.println("Your test scores are Test 1: "+test1+" Test 2: "+test2+" Test 3: "+
  39. test3+ " Your average is: "+ average);
  40. }
  41. }
Runtime error #stdin #stdout #stderr 0.11s 3359744KB
stdin
12
stdout
Enter score for Test 1: Enter score for Test 2: 
stderr
Exception in thread "main" java.util.NoSuchElementException
	at java.util.Scanner.throwFor(Scanner.java:862)
	at java.util.Scanner.next(Scanner.java:1485)
	at java.util.Scanner.nextDouble(Scanner.java:2413)
	at lab3part1.main(Main.java:32)