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.
Alright, so, for my CS project, we're supposed to list diving scores. However, there are four sections (which I've made in the code) and each section has 9 scores. Of those nice scores, the highest and lowest must be eliminated and then the total needs to be figured out. We're supposed to be using arrays for this...
import java.util.Scanner; import java.io.File; import java.io.FileNotFoundException; public class Diving { public static final int MAX_DIVES = 51; public static void main (String[] args) {
[Code] .....
The text file link is uploaded on this post.File is here:
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];
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.
I mainly would like to know is a int[4][4] or a int [4*4] is more efficient to use. Which takes more storage? Which requires more to process? that kind of stuff.
So for this project I'm going to take in some quiz scores, then eventually get the total number, the range, the mean, and others... Here's the instructions for the two methods I need to create but am completely stuck on:
2. public boolean inputData(Scanner in) 2.1.takes in a Scanner object passed in from main() 2.2. asks the user for a number in the range of 0 through 100. 2.3.It must read a number into an integer variable unless a non-number value is entered, in which case the method will return false. You may use try/catch or an if statement for this. 2.4.If the datum/score seems acceptable, the addGrade method must be called. 2.5.If addGrade returns false, then inputData should throw an IllegalArgumentException or return false Otherwise, inputData should return true. See section 11.4 for exceptions.
3. public boolean addGrade 3.1.takes in an integer grade. If grade is not in the range of 0 through 100 the method should return false. Otherwise, it should appropriately change the values of numberOfQuizzes, highValue, lowValue, 3.2.totalQuizScore , sumOfSquares (used in variance calculation), and add one to the count of the proper variable for A's, B's, C's, D's or F's. The method should then call calculate and return true
Now I have done very little with booleans in class at all, so this is all very confusing for me. I've tried to do a lot of research on my own and so far I came up with the following for the two methods above:
public boolean inputData() { int score = 0; System.out.println("Please enter values, Q to quit:"); Scanner in = new Scanner(System.in); while (in.hasNextInt())
[Code] ....
Honestly I'm not really sure what I'm doing wrong at all, and I have done a lot of research but can't really find anything too similar to what the instructions want so I'm not sure what's right/wrong.
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
I am doing an assignment where I have to find the price per square inch of a pizza, compare them and display the results. I have everything figured out with the values and stuff. Now when I have to displays the results I have to display which of the two pizzas is more favorable.
I have both values / square inch for both. and I know how to find the minimum value of the two wit the Math.min class. My question is how can I assign the char, PIZZA A to the value that I had so I can display it in the output statement, without writing PIZZA A. It should display after the difference is calculated.
Here's my code so far.
// This programs finds the price per square inch of a pizza
import java.util.Scanner; import java.text.DecimalFormat; public class PizzaSquareInches { public static void main(String[] args) { Scanner input = new Scanner(System.in); DecimalFormat df = new DecimalFormat("#.###");
Design and write a Java program that will generate a set of test scores between 0-100, inconclusive. The exact umber of scores is determined either randomly or by the user input. There should be a minimum of 5 test scores. The program calculates the average of all test score in this data set. Then it asks the user how many scores are to be dropped and drops that number of low scores. The average is recalculated.
Output of this program:
The original test scores printed in rows of 10 scores The average before low scores are dropped The number of low scores to be dropped The list of low scores dropped The new average
I'm writing a program that is about rolling "dice" and getting the scores to add up to 100. There are two players in the game and each must take turns rolling dice choosing whether or not to keep rolling dice and accumulating more points during their turn while risking their points being lost by rolling a 1 or to add their turn points to their total points. The question I have is how would I exit the do while loop if the player chooses to add their turn score, thus adding their score and ending their turn?
Here is the coding so far.
Java Code:
import java.util.Scanner; import java.util.Random; public class Pig { public static void main(String[] args) { int die; int userTotalScore; int userTurnScore; int compTotalScore; int compTurnScore;
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
simple assignment of values to a previously initialized object?
See the method useModel ()
The idea is, assign the values to the temporary object, data
Then plunk it into this statement:
model.addRow ( data );
Simple enough?
I've been putzing with the syntax for multiple hours, over days, now.
With and without
[0];,
Netbeans keeps giving me: Illegal start of expression data is declared as an array of Object, although, in this case, it does not need to be an array. What is the correct syntax?
I've been referencing my text and a few other sites to assist in building this class...and I'm still uncertain of the purpose of a few of the methds: next(), hasNext().
Also, I have not found a clear explanation of the following code example: tail.next = tail; There are several instances of this in the code below....I'm just not sure exactly how this assigns the value to the next object in the other class..?? ??
public class MySinglyLinkedList<T> implements SinglyLinkedList<T>{ protected NodeList<T> head, tail, current, newNode; String name; int size = 0; public MySinglyLinkedList(){ head = null; tail = null;
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;
I have a project that is asking me to create a program that will handle a Golfer and his scores. The program will be comprised of three classes: a Golfer class that will manage all the golfer's scores, a Score class and a Tester class to drive the other classes. To accomplish this task the program will use a partially filled array to store the golfer's scores. I have the majority of the code written. It compiles fine, but when I compile and run it only gives the following output.
Tiger ID Number: 1001 Home Course: Pebble Beach Score Date Course Course Rating Course Slope [LScore;@15db9742
I am not sure what I am doing wrong. I have been over and over the code. It is also only printing one golfers information. I have tried creating a for loop for the for the toString in the Golfer class but I am getting the following error Golfer.java:117: error: missing return statement.
I am at a loss here is the code I have for the three sections.
public class Golfer { private String name; private String homeCourse; private int idNum; private Score[] scores; private static int nextIDNum = 1000;
i am a french student in France and i am studying informatics . For validating my term at the beginning of January i have a projet in JAVA to do called YAHTZEE. It's a game which i have to code WITHOUT USING AN OBJECTS. I already started the coding, i did all the beginning stuff ( to call the number and the names of players, to roll the 5 dices, i made the code for all the scoring points too(rules) ) but i can't do the table score which updates the new scores after each turn ( 3 turns in total) .
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++){