Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lesson;
- // write a program hat uses the JOptionPane to calc the avg of three test scores
- //program should ask user for three test scoresand calc avg,
- //if avg >= 95 output "thats a great score"
- // avg
- import javax.swing.JOptionPane;
- public class IfStatment
- {
- public static void main(String[] args)
- {
- String s;
- double s1, s2, s3, avg;
- JOptionPane.showMessageDialog(null,"this program will find the average of three text scores");
- s = JOptionPane.showInputDialog("enter test score 1");
- s1 = Double.parseDouble(s);
- s = JOptionPane.showInputDialog("enter test score 2");
- s2 = Double.parseDouble(s);
- s = JOptionPane.showInputDialog("enter test score 3");
- s3 = Double.parseDouble(s);
- avg = (s1+s2+s3)/3.0;
- if (avg >= 95 )
- {
- JOptionPane.showMessageDialog(null,"Thats a great score");
- }
- System.exit(0);
- //comparison operators
- // '==' equality operator
- // >, < greater/ less than
- // >=, <= greater/less than or equal to
- // != not equal to
- }
- }
Add Comment
Please, Sign In to add comment