Question

Introducing JOptionPane. The Learning Goal for this exercise is to interact with a user with JOptionPane...

Introducing JOptionPane.

The Learning Goal for this exercise is to interact with a user with JOptionPane and use that instead of Scanner for user input and output.

PowerShell or Terminal is not a standard way that users interact with programs. Windows and dialog boxes are very natural. JOptionPane will allow you to get information to and from a user.

Create a Calculator that will calculate the grade in this course.

_Create a Java Program that can calculate your final grade based on:

_Attendance 10% (In order to receive any attendance credit, you must earn at least 6 of the 10 points.), Weekly quizzes 10%, weekly class assignments 10%, lab 10%, project1 20%,project 2 20%, homework 40% ...The grading scale expected to be used is: A >= 90% > B >= 80% > C >= 70% > D >= 60% > F... Late work will receive a 30% reduction.

_Use a dialog box to welcome the user and tell them what the program does.

_For Attendance, enter the points earned, from 0-13, but follow the rules for no points if less than 6 points are earned.

_For gather quizzes, use the average of the quizzes from 0-10

_For all other categories, use a 0-100 scale for the total grade in that category (not individual grades) and then weight it just as described in the syllabus.

_Each click of OK will enter the grade being asked for and move to the next grade.

_When asking for a grade, include what the grade is for and then give the expected range as an example.

_After all grades are entered, display the numeric grade with 2 decimal places. example 92.54 and the letter grade earned.

_Accept user input and display output through JOptionPanes - do not use System.out.print...

_Use the javac command to compile your code.

_Use the java command to evaluate the results of your code.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

There seems to be a problem with the percentage in the given problem (all the percentages add to 110%).

But, the solution in java source code is given below:-

//----------------------------------------------------------------------------------------------------------------------------------------------

import java.lang.*;
import javax.swing.JOptionPane;

public final class Grades
{
   public static void main(String[]args)
   {
       int reply=0; // this variable stores whether the submission was late
       int attd = 0; // the attendance points (from 0 to 13)
       int quiz = 0; // the average points for quizzes (from 0 to 10)
       float assign = 0; // the average marks for assignments (from 0 to 100)
       float lab = 0; // the average marks for laboratory experiments (from 0 to 100)
       float proj1 = 0; // the average marks for first project (from 0 to 100)
       float proj2 = 0; // the average marks for second project (from 0 to 100)
       float homew = 0; // the average marks for homework (from 0 to 100)
       float marks=0; // total marks
       char grade='X'; // overall grade
       // Welcome the user and display what the program does
       JOptionPane.showMessageDialog(null,"Welcome!\n This program various marks & points as input\n and then displays overall marks and grade.");
       // taking inputs
           attd = Integer.parseInt(JOptionPane.showInputDialog("Enter Attendance(0-13):-"));
           quiz = Integer.parseInt(JOptionPane.showInputDialog("Enter Average of Quizzes(0-10):-"));
           assign = Float.parseFloat(JOptionPane.showInputDialog("Enter the Percentage of Assignments:-"));
lab = Float.parseFloat(JOptionPane.showInputDialog("Enter the Percentage of Marks in Laboratory:-"));
  
           proj1 = Float.parseFloat(JOptionPane.showInputDialog("Enter the Percentage of First Project:-"));
  
           proj2 = Float.parseFloat(JOptionPane.showInputDialog("Enter the Percentage of Second Project:-"));
  
           homew = Float.parseFloat(JOptionPane.showInputDialog("Enter the Percentage of Homeworks:-"));

       reply = JOptionPane.showConfirmDialog(null,"Was any of the Submission late?", "LateSubmission", JOptionPane.YES_NO_OPTION);
       // the calculations of total marks is below:-
       if(attd>=6) // attendance points are only awarded if there are more than 6 points
           marks += attd*(10/13); // 10% of attendance
       marks += quiz; // 10% of quiz
       marks += assign*0.1; // 10% of assignments
       marks += lab*0.1; // 10% of lab
       marks += proj1*0.2; // 20% of first project
       marks += proj2*0.2; // 20% of second project
       marks += homew*0.4; // 40% of home work
       if(reply == JOptionPane.YES_OPTION) // if the submission was late
       {
           marks -= 30;
}
       // assigning a grade
       if(marks>=90)
       {
           grade = 'A';
       }
       else if(marks>=80)
       {
           grade = 'B';
       }
       else if(marks>=70)
       {
           grade = 'C';
       }
       else if(marks>=60)
       {
           grade = 'D';
       }
       else
       {
           grade = 'F';
       }
       // showing output
       JOptionPane.showMessageDialog(null,"Total Marks: "+marks+" %\nTotal Grade: "+grade);
   }
}

//------------------------------------------------------------------------------------------------------------------------------------

// To compile this class simply save it with filename 'Grades.java'.

// Then change the directory to the location of the source file.

// Then type:-

// javac Grades.java

//---------------------------------------------------------------------------------------------------------------------------------------

// To run this program type:-

// java Grades

Add a comment
Know the answer?
Add Answer to:
Introducing JOptionPane. The Learning Goal for this exercise is to interact with a user with JOptionPane...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT