LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 692 users online 225428 members 1455 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
SpartanElite
Peeves: people who just dont stop talking in a...
Mood: Hopeless
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
3 online / 54 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic

Need Help with Code
Replies: 7Last Post Nov. 11, 2006 7:10pm by Jcash22
Welcome to LiveWire!
We're Stronger Together.
Join the Community
Single page for this topic Email Print Favorite
( Jcash22 )


Dairy Product Addict
Reply
I'm trying to write a code where after i write a code the program should display the average score and the letter grade. I can get the average but i can't get the letter . And im not sure if this code is right. tell me what i am doing wrong and how to fix it... here it is...
i
mport javax.swing.JOptionPane;  // Needed for JOptionPane

/**
  This program demonstrates the if statement.
*/

public class TestScoresAndGrades
{
  public static void main(String[] args)
  {
     double score1;    // To hold score and letter grade #1
     double score2;    // To hold score and letter grade #2
     double score3;    // To hold score and letter grade #3
     double average;   // To hold the average score
     String input;     // To hold the user's input

     // Get the first test score.
     input = JOptionPane.showInputDialog("Enter score #1:");
     score1 = Double.parseDouble(input);
     
     // Get the second score.
     input = JOptionPane.showInputDialog("Enter score #2:");
     score2 = Double.parseDouble(input);

     // Get the third test score.
     input = JOptionPane.showInputDialog("Enter score #3:");
     score3 = Double.parseDouble(input);
     
     // Calculate the average score.
     average = (score1 + score2 + score3) / 3.0;
     
     // Display the average score.
     JOptionPane.showMessageDialog(null,
                               "The average is " + average);
     // Display the letter grade.
     input =  JOptionPane.showInputDislog(null,
     "The letter grade is" + letter);
     
     // If the score was greater than 95, let the user know
     // that's a great score.
     if (average > 95)
        JOptionPane.showMessageDialog(null,
                               "That's a great score!");
       
     System.exit(0);
  }


6:37 pm on Nov. 11, 2006 | Joined: May 2005 | Days Active: 396
Join to learn more about Jcash22 New York, United States | Posts: 410 | Points: 4,369
Single page for this topic Email Print Favorite

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic