I am tasked with creating several JPanels each of which has a title centered at the top. As such I have created parent panel that each panel extends. However, I am uncertain as to whether drawing the string on the panel or using a JLabel is the best solution. The panels might allow dynamic resizing...
i would like to create a menu like below where if i clicked on "DRAW", a frame to draw will appear and when i clicked on animate, I can animate an object drawn. I tried on using JButton, but I donno how to customize the design n so I would like to know is there other ways so tat my menu will appear as below?
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.
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'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
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++){
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;
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");
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 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.
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 ..
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();
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{
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
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 ;
// 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)"
//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.
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 ="";
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:");
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:");
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;
In this project each individual will create a data analysis program that will at a minimum,
1) read data in from a text file, 2) sort data in some way, 3) search the data in some way, 4) perform at least three mathematical manipulations of the data, 5) display results of the data analysis in numeric/textual form, and 6) display graphs of the data. In addition, 7) your program should handle invalid input appropriately and 8) your program should use some "new" feature that you have not been taught explicitly in class.
(Note: this is to give you practice learning new material on your own - a critical skill of today's programmer.) If you do not have a specific plan in mind for your project, below is a specific project that meets all of the qualifications as long as 7) and 8) are addressed in the implementation.
Everything is done except I need to call my methods in my GradeTester.
GradeBook:
/** *This class creates an array called scores. *This class determines the length of the array scores and determines the last grade in the array scores. *This class sorts the array using a bubble sort, and searches the array. *This class calculates the mean, standard deviation, and the median of the grades in the array scores. *Once the grades in the array is sorted, the class then calculates the highest and lowest grades in the array. */
public class GradeBook { public final int MAXARRAY_SZ = 20; double [] scores = new double [MAXARRAY_SZ]; int lastGrade = 0; double mean = 0;