Make GPA Calculator For 5 Courses Of Grades
Nov 7, 2014
I have to make a gpa calculator for 5 courses of grades A B+ C+ D F, and worth 4, 3.5, 3, 2.5, 2,1,0 respectively. using 10 input text boxes, and a button
Create two arrays of length 5: one to hold the numerical values of letter grades, the other to hold the number of credit hours. Initialize both to have 0’s. Write a function that takes a letter grades entered by a user and returns its numerical equivalent.
Use an ‘if…else if… else’ construct.
Write a function that can operate on the two arrays and return the GPA. Use a for loop that runs from 0 to 5, multiplies the corresponding array elements and adds them together, divides that total by the total number of credit hours, and returns that value.
Input elements:
In the first 10 textfields, use the onchange attribute to fill the arrays with user entries.
Hint: For the course grade entries it should look like
onchange= ‘array1[0] =
first_function(this.value)’ etc.
The button should make the value of the last text area equal to the return value of the second function.
i have my whole code completed but when i press the button it returns the points value '0' so i think there is an error in my if else statements (ltonum function)
<DOCTYPE! html>
<html>
<head>
<title> Assignment 9: Javascript 3
</title>
<!-- Assignment 9, Due November 8, 2014, Jamie Zajac, TA Kartik-->
<style>
body
{
background-color: lemonchiffon;
color: midnightblue;
[Code] ....
View Replies
ADVERTISEMENT
Jul 17, 2014
where to create the array of chars that hold the letter grade. I am assuming that would be in the main with the other arrays. Passing it into an object creating a method in the record.java. Then displaying it in my main.
Take the Grades program and make a class. An object that hold 5 student names, an array of 5 chars that hold the letter grades, 5 arrays of four doubles each to hold the set of test scores. The class should have methods that return a specific student's name, average test score and a letter grade based on the average. Demonstrate the class in a program that allows the user to enter each student's name and their 4 tests scores. It should then display each student's average and letter grade.This is my main program:
import java.util.Scanner;
public class GradeBook{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
Record[] students = {new Record(), new Record(), new Record(), new Record(), new Record()};
for(int j=0; j < 5; j++){
[code]....
View Replies
View Related
Feb 5, 2014
I got to make a java code for my class. I must make a calculator using stacks. I have a code but i got some mistakes. Here is the code
Java Code:
package stackscalc;
import java.util.Scanner;
import java.util.Stack;
import java.util.EmptyStackException;
class Arithmetic {
int length;
Stack stk;
String exp,
[Code] .....
View Replies
View Related
Jul 29, 2014
I am trying to make a calculator using Java GUI. I've managed to make an ActionListener and add it to a button, but I've made an error in my code that I'm unsure of how to solve. Because of how I've written the code, only one number can be placed in the text field. For example, the an ActionListener for the three button on the calculator was added to the button, but no matter how many times the user presses the button, only one 3 will appear in the text field. The code is below:
import javax.swing.*;//import the packages needed for gui
import java.awt.*;
import java.awt.event.*;
public class Calculator {
public static void main(String[] args) {
JFrame window = new JFrame("Window");//makes a JFrame
window.setSize(300,350);
[code].....
As you can see, because the compiler forces the String variable to be final, so when the user presses the button, the code simply shows how a space character and three character would look like, because the String variable can't change. How do I write my code so that every time the user presses the button, a character is added to the text field?
View Replies
View Related
Feb 4, 2014
i got a problem with this program.I am supposed to make a calculator using stacks but it seems that i m stack. i can t get the right recognition
for () and {} []
its not necessary to use all these symbols.just a simple () will do .here s the program
package stackscalc;
import java.util.Scanner;
import java.util.Stack;
import java.util.EmptyStackException;
class Arithmetic
{
int length;
Stack stk;
String exp,
postfix;
[code]....
View Replies
View Related
Apr 30, 2015
I want to make a calculator program as my first ever program and I've been working on the layout and I think I have it close to where I want it but will probably tweak it in the future after I get it to work. My problem is I'm trying to add a MenuBar to it but it is not showing up. I tried having it all over my code but whereever I put it the MenuBar doesn't show up.
public class MySecondCalculator extends JFrame {
JTextArea screen;
JMenuBar mb;
JMenu file;
JMenuItem open;
JButton one, two, three, four, five, six, seven, eight, nine, zero, decimal, add, subtract, multiply, divide, equals;
[code]....
View Replies
View Related
Mar 11, 2015
i am working on my assignment in Compro 2, we are ask to make a simple calculator program
here's my code;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JFrame;
import java.awt.BorderLayout;
[code]...
View Replies
View Related
Aug 18, 2014
Write a Swing program that declares an empty array of grades with a maximum length of 50. Implement a JOptionPane input box within a while loop to allow the user to enter grades. When the user enters the sentinel value of -1, that will signal the end of the data input loop.
After the grades are entered, a content pane should display the grades sorted from lowest to highest. Write a loop that goes through the array looking for elements that are greater than zero (0). Keep a running count of those items, and also accumulate them into a grand total. Divide the grand total by the number of grades entered to find an average, and display the average at the end of the sorted list of grades. Use the DecimalFormat method to display the average to 2 decimal places.
View Replies
View Related
Mar 7, 2014
here is the code i already have made;
import java.awt.*;
import javax.swing.*;
public class EX_7_2 extends JFrame
{
public EX_7_2()
{
setLayout(new BorderLayout(5, 10));
[Code] ....
View Replies
View Related
Sep 14, 2014
So I have created this program but I am having a couple of small problems with it. The first problem is that the user inputted numbers should all be on the same line. I have spent hours trying to figure this out and I have looked online but I've had no luck. The second problem is that the "lowest score" should be 42 and not 42.0. I don't understand how to make it so the number is an integer. I have posted the output that i'm getting and the way the output should look like at the bottom.
import java.util.Scanner;
public class Random
{
public static void main(String [ ] args) {
Scanner input = new Scanner(System.in);
double a, b, c;
[Code] .....
This is the output that i'm getting.
Enter three scores: 87
42
94
The average is: 74.33333333333333
The lowest score was: 42.0
The average without the lowest score is: 90.5
The grade is: A
This is the way the output should look like.
Enter three scores: 87 42 94
The average is: 74.33333333333333
The lowest score was: 42
The average without the lowest score is: 90.5
The grade is: A
View Replies
View Related
Apr 23, 2015
I've been asked to write a program that uses an array of grades, and to tally how many A's, B's etc ... The tallies are coming up incorrectly ... I'm putting the instructions at the end of this post to show what I should be getting.
import javax.swing.JOptionPane;
public class GradeCalculation {
public static void main(String[] args) {
//define array, grade values, and tally the amount of each grade
int grade[] = { 90, 100, 80, 85, 63, 73, 80, 92, 90};
int sum = 0;
int gradeA = 0;
int gradeB = 0;
[Code] ....
The assignment: Add logic inside the for loop to test if the number is between 90 and 100. If it is in this range, then add 1 to the tally of a gradeA. You should have another test to see if the number is between 80 and 89 and if it is it should add 1 to the tally of gradeB. You should continue to have tests for 70 to79 being gradeC; 60-69 being graded; and below 60 as being gradeF. After the for loop is done, you should display a list of how many students had A's, B's, etc. in the output message box.
Then the message box should display something like this:
The sum is 753
The average is 83
The largest test score is 100
The lowest test score is 63
The number of students with scores of 90-100 (A) is 4
The number of students with scores of 80-89 (B ) is 3
The number of students with scores of 70-79 (C ) is 1
The number of students with scores of 60-69 (D) is 1
The number of students with scores below 60 (F) is 0
View Replies
View Related
Sep 29, 2014
I have an assignment that I need to create a menu like this using only arrays.
Main Menu:
1. Input how many students.
2. Input names and grades
3. Print name and grades.
4. Exit
I dont know how to do them in array.
View Replies
View Related
Jan 31, 2014
/*This program will convert integer grades to letter grades and say how many A's, B's, C's, D's , F's do we have
public class DSlab3 {
private char LetterGrades;
private int IntegerGrades;
//default constructor
public DSlab3() {
LetterGrades =' ';
IntegerGrades = 0;
[Code] .....
View Replies
View Related
Jan 20, 2015
I want to reverse grades that i have put using JOptionPane from largest to smallest and the corresponding names..
import javax.swing.*;
import java.util.Arrays;
public class ArrayUtils {
public static void main (String[]args){
String length = JOptionPane.showInputDialog("Number of students");
[code]....
View Replies
View Related
Nov 12, 2014
For my lab this week I have to print out four arrays. The arrays have to be 5 units long. The first three arrays are the student's exam grades for exam 1, 2 & 3 and the fourth array should be the average for each student's three tests. The program should ask the user to input the grades in and then the program should compute the average. For example the program should print this if these are the exam grades the user imputs:
Exam 1 Exam 2 Exam 3 Average
65 79 80 74.66
79 82 59 73.33
99 100 98 99
and so on.......
I thought I wrote the program perfectly and when I compile it there are no errors but when I run it, it only lets me input the numbers for the first three students and then prints out something so strange.
here is my program:
public class Lab9{
public static void main(String[] args){
java.util.Scanner input = new java.util.Scanner(System.in);
int i, sum;
double avg;
sum = 0;
int A[ ] = new int [5];
int B[ ] = new int [5];
int C[ ] = new int [5];
double avg1[ ] = new double[5];
[code]....
View Replies
View Related
Oct 10, 2014
Write a program that reads student scores, gets the best score and then assigns grades based on the following scheme:
Grade is A if score is >= best - 10;
Grade is B is score is >= best - 20;
Grades is C if score is >= best - 30;
Grade is D if score is >= best - 40;
Grde is F other wise;
The program prompts the user to enter the total number of studeents, then prompts the user to enter all of the scores, and concludes by displaying the grades.
import java.util.*;
public class AssigningGrades
{
public static void main(String [] args)
{
Scanner scan = new Scanner(System.in);
int studentNumber = 0;
int classScore = 0;
[Code] ....
So when I ran into problems when populating the array and I made changes. Then all of a sudden the program doesn't recognize classSize[i] at the System.out.print line.
View Replies
View Related
Apr 8, 2014
prompts user for the grades of each of the students and saves them an int array called grades. Your program shall check that the grade is between 0 and 100. program should then check if the grade is equal to or greater than 50, where 50 is the pass rate.
A sample output :
Enter the number of students: 3
Enter the grade for student 1: 55
Enter the grade for student 2: 108
Invalid grade, try again...
Enter the grade for student 2: 56
Enter the grade for student 3: 57
The average is 56.0
The maximum is 57
The minimum grade is 55
The number of fails is 0
The number of passes is 3
..
I am quiet stuck on this one.
View Replies
View Related
Jan 28, 2015
package Program1;
import java.util.Scanner;
public class Source1 {
[Code].....
using netbeans to debug the program but i'm not sure what I did wrong as it doesnt go past test 1
View Replies
View Related
Nov 25, 2014
The program is just a simple one to print grades using only methods. The problem is Im trying to use a returned value in another method but the compiler keeps telling me it cannot find the symbol "mark". the problem areas are marked in blue. I am basically trying to input a value into the keyboard and then use it in another method.
public static void main(String[] args) {
printTitle();
enterMark();
gradeCalculator(mark);
printGrade();
[Code] .....
View Replies
View Related
Aug 3, 2014
I wrote a java application that coverts number grades to letter grades. Here is what it looks like:
/java application to That corresponds the letter grade with the number grade
import java.util.Scanner; //program uses the class scanner
public class gradescore{
[Code]....
View Replies
View Related
Sep 2, 2014
I'm using Jgrasp and my prompt is asking me to write a program where the program prompts the user to enter 4 grades between 0 and 100. And you have to display the grades, and the program has to calculate the minimum grade, the maximum grade and the average.I'm just having problems with the max?
// Import Java Scanner.
import java.util.Scanner;
// Name Class.
public class Practice_4_1
[code]...
View Replies
View Related
Apr 30, 2015
package question.pkg3;
import java.util.Scanner;
public class Question3 {
public static void main(String[] args) {
// TODO code application logic here
Scanner Luka=new Scanner(System.in);
double sum=0;double count=0;
int[] a=new int[10];
[code]....
I'm required to write a program that allows the user to enter up to 10 integer grades into an array. Stop the loop by typing in ‐1. Your main method should call an Average method that returns the average of the grades.I There's something wrong with my program , the count always stays 0 and the sum is always 1 less than the actual sum.Sample input and output :
Enter grade 1: 8
Enter grade 2: 9
Enter grade 3: 10
Enter grade 4: 5
Enter grade 5: 8
Enter grade 6: 9
Enter grade 7: -1
output
Average grade is 8.1666666667On line 13 I had count=count+1 ;
View Replies
View Related
Nov 4, 2014
// GradeBook class uses switch statement to count A, B, C, D and F grades.
import java.util.Scanner;
public class GradeBook
{
private String courseName;
private int total;
private int gradeCounter;
private int aCount;
[Code] .....
Then eclipse told me that:
"Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at chapter5_control_statements_II.GradeBook.inputGrades(GradeBook.java:52)
at chapter5_control_statements_II.GradeBookTest.main(GradeBookTest.java:11)"
View Replies
View Related
Nov 10, 2014
//Use a Switch statement to determine outcomes for letter grades
switch (Letter)
{
case 'A': outFile.println("
Good Work! You have met the pre-req for CIS 220.");
break;
case 'B': outFile.println("
[Code] ....
is not printing the information on the next line in my output file.
View Replies
View Related
May 3, 2014
import java.util.*;
import java.text.*;
public class Quiz {
public static void main(String[] args){
Scanner s= new Scanner(System.in);
int quests = 0;
String input ="";
[code]....
I'm not getting any errors anymore.
View Replies
View Related
Nov 17, 2014
So I have re-written the code but it is still not running correctly. Any number i type in it throws an exception, also i need the program to add the totals that i type in and then once i type -1 into the prompt button list all the number i typed in and give me the average.
import java.awt.*;
import java.awt.event.*;
import javax.swing .*;
import javax.swing.text.*;
public class Averages extends JFrame
{
//construct components
JLabel sortPrompt = new JLabel("Sort By:");
[Code] .....
View Replies
View Related