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
  • Open the Chang Solution (Chang Solution.sln) file contained in the VbReloaded2015\ Chap11\Chang Solution folder. The application...

    Open the Chang Solution (Chang Solution.sln) file contained in the VbReloaded2015\ Chap11\Chang Solution folder. The application should display a grade based on the number of points entered by the user. The grading scale is shown in Figure 11-47. Create a structure that contains two members: an Integer variable for the minimum points and a String variable for the grades. Use the structure to declare a class-level one-dimensional array that has five elements. The MainForm_Load procedure should store the minimum points...

  • Java programming only Create a Java program that inputs a grade from the user. The grade input from the user will be an...

    Java programming only Create a Java program that inputs a grade from the user. The grade input from the user will be an integer. Once the input is stored, use an if-else-if block of code to determine the letter grade of the inputted integer grade. Do not use a bunch of if statements by themselves to solve this problem. You will print an error message for inputs greater than 100 and for inputs less than 0. Both errors must be...

  • Project 4: Month-end Sales Report with array and validation Input dialog box for initial user prompt...

    Project 4: Month-end Sales Report with array and validation Input dialog box for initial user prompt with good data and after invalid data Input OK Cancel Input dialog boxes with sample input for Property 1 Ingut X Input Enter the address for Property 1 Enter the value of Property 1: OK Cancel Input dialog boxes after invalid data entered for Property 1 Error Please enter anmumber greater than D Ester the walue of Peoperty t Console output END SALES REPORT...

  • Homework 3: Input Validation 1   Objectives control structures console-based user input using Scanner class writing complete...

    Homework 3: Input Validation 1   Objectives control structures console-based user input using Scanner class writing complete programs using two classes: client and supplier 2   User Interface Specification This is a console-based I/O program. Display should go to System.out (print or println) and the program will get user input using the Scanner class. The flow of execution should be as follows: When the program starts, display a one-line introduction to the user Display a menu with 5 options 1. validate zip...

  • Complete the missing parts of java source code //This program calculates a running total. Here is...

    Complete the missing parts of java source code //This program calculates a running total. Here is the problem definition //Data Express, an Internet Service Provider, has requested that you develop a program to allow //sales representatives to calculate a running total of their sales based on a number of days. //The program prompts the salesperson “How many days do you have sales figures? “. //The number of days must be between 1 – 4 days (keep asking the user until...

  • /** * File: GradeCalculator . java * Description: Instances of this class are used to calculate...

    /** * File: GradeCalculator . java * Description: Instances of this class are used to calculate * a course average and a letter grade. In order to calculate * the average and the letter grade, a GradeCalculator must store * two essential pieces of data: the number of grades and the sum * of the grades. Therefore these are declared as object properties * (instance variables). * Each time calcAverage (grade) is called, a new grade is added to *...

  • using java Program: Please read the complete prompt before going into coding. Write a program that...

    using java Program: Please read the complete prompt before going into coding. Write a program that handles the gradebook for the instructor. You must use a 2D array when storing the gradebook. The student ID as well as all grades should be of type int. To make the test process easy, generate the grade with random numbers. For this purpose, create a method that asks the user to enter how many students there are in the classroom. Then, in each...

  • Java Programing Code only Ragged Array Assignment Outcome: Student will demonstrate the ability to create and...

    Java Programing Code only Ragged Array Assignment Outcome: Student will demonstrate the ability to create and use a 2D array Student will demonstrate the ability to create and use a jagged array Student will demonstrate the ability to design a menu system Student will demonstrate the ability to think Program Specifications: Write a program that does the following: Uses a menu system Creates an array with less than 25 rows and greater than 5 rows and an unknown number of...

  • In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a tes...

    In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a test grade (integer value) for each student in a class. Validation Tests are graded on a 100 point scale with a 5 point bonus question. So a valid grade should be 0 through 105, inclusive. Processing Your program should work for any...

  • Need code written for a java eclipse program that will follow the skeleton code. Exams and...

    Need code written for a java eclipse program that will follow the skeleton code. Exams and assignments are weighted You will design a Java grade calculator for this assignment. A user should be able to calculate her/his letter grade in COMS/MIS 207 by inputting their scores obtained on worksheets, assignments and exams into the program. A skeleton code named GradeCompute.java containing the main method and stubs for a few other methods, is provided to you. You must not modify/make changes...

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