476179

If Statment - Java2

Oct 22nd, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. package lesson;
  2. // write a program hat uses the JOptionPane to calc the avg of three test scores
  3. //program should ask user for three test scoresand calc avg,
  4. //if avg >= 95 output "thats a great score"
  5. // avg
  6. import javax.swing.JOptionPane;
  7. public class IfStatment
  8. {
  9.  
  10. public static void main(String[] args)
  11. {
  12. String s;
  13. double s1, s2, s3, avg;
  14. JOptionPane.showMessageDialog(null,"this program will find the average of three text scores");
  15. s = JOptionPane.showInputDialog("enter test score 1");
  16. s1 = Double.parseDouble(s);
  17. s = JOptionPane.showInputDialog("enter test score 2");
  18. s2 = Double.parseDouble(s);
  19. s = JOptionPane.showInputDialog("enter test score 3");
  20. s3 = Double.parseDouble(s);
  21.  
  22. avg = (s1+s2+s3)/3.0;
  23.  
  24. if (avg >= 95 )
  25. {
  26. JOptionPane.showMessageDialog(null,"Thats a great score");
  27. }
  28.  
  29. System.exit(0);
  30. //comparison operators
  31. // '==' equality operator
  32. // >, < greater/ less than
  33. // >=, <= greater/less than or equal to
  34. // != not equal to
  35.  
  36. }
  37.  
  38. }
Add Comment
Please, Sign In to add comment