Create A Program That Shows Three Test Grades And Average
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
ADVERTISEMENT
Apr 13, 2014
I keep getting an error that says variable can't be found, what am I missing?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.util.Scanner;
public class testscores extends JFrame
[code]...
View Replies
View Related
Oct 26, 2014
My homework assignment is: Using a do-while statement, write a Java program that continuously requests a grade to be entered. If the grade is less than 0 or greater than 100, your program should display an appropriate message informing the user that an invalid grade has been entered; a valid grade should be added to a total. When a grade of 999 is entered, the program should exit the repetition loop and compute and display the average of the valid grades entered. Run the program on your computer and verify the program using appropriate test data.
When I run it, I don't get the correct average. I know that i'm supposed to enter 999 to exit the loop and to display the average, but 999 is being added with the loop. I'm not sure how to make it not do that.
//stephanie
import java.util.Scanner;
public class gradeAverage
{
public static void main(String[] args)
[code]....
View Replies
View Related
Jun 16, 2014
I'm working on a homework assignment and I keep getting a compiler message this is the message
GradesAverage.java:44: error: variable totalgrade might not have been initialized
System.out.println("Over all you have " + totalgrade);
^
1 error
The homework is this Write a program that has variables to hold three test scores. The program should ask the user to enter three test scores and then assign the values entered to the variables. The program should display the average of the test stores and the letter grade that is assigned for the test score average. Use the grading scheme in the following table:
Test Score Average Letter Grade
90-100 A
80-89 B
70-79 C
60-69 D
Below 60 F
This is my code
import javax.swing.JOptionPane; // Needed for JOptionPane class
import java.util.Scanner; // Needed for the scanner class
public class GradesAverage
{
public static void main (String[] args)
[code]....
View Replies
View Related
Apr 2, 2015
Four experiments are performed, each consisting of six tests. The number of test results for each experiment is entered by the user. Write a Java program using a nested loop to compute and display the average of the test results for each experiment.
You can run the program by entering the following test results:
Experiment 1 results:23.231.516.927.525.428.6
Experiment 2 results:34.845.227.936.833.439.4
Experiment 3 results:19.416.810.220.818.913.4
Experiment 4 results:36.939.549.245.142.750.6
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
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
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
Apr 17, 2015
Write a program in JAVA in response to the following prompt:
Design a GUI program to find the weighted average of four test scores. The four test scores and their respective weights are given in the following format:
testscore1 weight1
...
For example, the sample data is as follows:
75 0.20
95 0.35
85 0.15
65 0.30
The user is supposed to enter the data and press a Calculate button. The program must display the weighted average.
Here is what I have written:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class weightedaverage2 extends JFrame {
private JLabel Score1L,Score2L,Score3L,Score4L;
[Code] .....
View Replies
View Related
Jan 15, 2014
I am using jdev12c. I tried to create the following class
package view;
import java.awt.Dimension;
import java.util.ListResourceBundle;
public class Resource extends ListResourceBundle {
protected Object[][] getContents() {
return new Object[][] = {
[Code] ....
The code is copied from java documentation ListResourceBundle (Java Platform SE 7 )
Looks like a documentation bug where "=" has to be removed
View Replies
View Related
Sep 24, 2014
Using Bluejay. Need code that prompts user to enter 5 test scores and their names. Calculate the average and display.
First initial and last name , 5 test scores, and average
View Replies
View Related
Oct 1, 2014
It has no errors in it, but when it runs, it just doesn't show any output at all. Here's my code.
Fuel Class:
public class FuelGauge {
// Setting the gallons and the total amount of gallons
private int gallons;
final static int TotalGallons=15;
public FuelGauge(){
gallons=0;
}
// Initiate the number of gallons
public FuelGauge(int gallons){
[Code] .....
View Replies
View Related
Jan 3, 2015
//constructor
class Base
{
Base(int a) {
System.out.println("in base"+a);;
}
}
class Cons extends Base
[Code] .....
View Replies
View Related
May 22, 2014
For my jsp file, the code editor shows no error, but the projects window shows an error. I built my project again, cleaned the project, restart eclipse twice and summoned cthulhu. But my project still shows an error. How do I find the cause.
Eclipse project -
JSP file -
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="mine" uri="DiceFunctions"%>
[Code] ....
View Replies
View Related
Apr 13, 2014
Write a program that shows a square frame filled with 100 buttons labeled 1 to 100. Nothing needs to happen when you press any of the buttons. I keep getting errors i am a beginner.
import java.awt.Frame;
import javax.swing.JButton;
import javax.swing.JPanel;
class TestFrame extends Frame {
[Code] ...
View Replies
View Related
Feb 19, 2015
class Brain56
{
public static int[] get()
{
return null;
}
public static void main(String...a)
{
int k=1;
get()[k]++;
}
}
when i remove the increment operator(get()[k]) program shows invalid statement may i know the reason behind it?
View Replies
View Related
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
Mar 2, 2015
In my programming class we need to create a large test array of Longs to iteratively sum/reverse the array and recursively sum/reverse the array.creating the array and where to go from there.
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 1, 2014
How do I use two constructors and I'm having trouble with using char for gender...
Write a program to test the Person class defined below. Your test program should create two instances of the class (each to test a different constructor) and test each of the methods. You are also required to illustrate the error in trying to access private data members from the client class (for clarity temporarily change the private modifier to public and test again). See screenshots below for sample output.
The screen shots are displayed as:
p1 name = Not Given Age = 0 Gender = U
p2 name = Jane Doe Age = 0 Gender = F
p1 name = John Doe Age = 25 Gender = M
and
PersonTester.jave:20: name has private access in Person
System.out.println("p2 name = " + p2.name + "Age = " + p2.age + "Gender = " + p2.gender);
PersonTester.jave:20: age has private access in Person
System.out.println("p2 name = " + p2.name + "Age = " + p2.age + "Gender = " + p2.gender);
PersonTester.jave:20: gender has private access in Person
System.out.println("p2 name = " + p2.name + "Age = " + p2.age + "Gender = " + p2.gender);
3 errors
Here is the class given :
class Person {
// Data Members
private String name; // The name of this person
private int age; // The age of this person
private char gender; // The gender of this person
[Code] .....
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
Sep 30, 2014
I do now have the problem where i have to insert the numbers 1 to 100 individually in order to allow the program to accept a grade as high as 100%.
Also as soon as i type in a negative number the system crashes and shows me a error as attached.
/*
Averaging grades
To use the Java Swing interface to calculate the average of up to 50 grades.Average is calculated once -1 is entered as a value. The grades are then sorted from lowest to highest and displayed in a content pane which also displays 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
Feb 2, 2015
Ok so I have my program working for the most part. In this program I am supposed to take input from the user until they enter a negative number and that works, the problem is that it doesn't work if I enter a negative number on the first prompt. For example if I enter a 100 it would prompt me again and if I enter a negative number it would quit and give me the average, but if I enter a negative number the first time I am prompted the program just gives me an error. How do I fix that?
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
public class Application {
public static void main(String [] args){
Scanner input = new Scanner(System.in);
List<Integer> grades;
[Code] ....
View Replies
View Related
Mar 25, 2014
I am new on this and I will be working in a gpa and average program. This is my code so far: Every time that I try to add the gpa part it gives me errors or just duplicates whatever I've in average and displays it in gpa
/**
* This program shows a database of students in a school.
* It gathers information as name, classes, grades, and calculates average and gpa average.
*
*/
import javax.swing.JOptionPane;
[code]....
View Replies
View Related