Saving Student Grades In Int Array - Pass Rate 50

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


ADVERTISEMENT

Student Grades For Three Exams And Average In Arrays?

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

Electricity Bill Project - How To Incorporate Rate Per Month And Three Rate Zones

Jan 30, 2014

I am not sure how to incorporate the rate per month and the three rate zones.

Problem: Electricity billing charges vary with the season and amount used.

Southwest Power and Light provides electricity at the basic rate of $ 0.10 per kilowatt for the months December through February, 0.12 per kilowatt for the months of March through May, and 0.15 per kilowatt for the remaining months.

Customer billing is divided into three rate zones: 0-350 kilowatts, 351 – 500 kilowatts, and above 500 kilowatts. Usage up to 350 kilowatts is billed at the basic rate. Usage between 350 and 500 kilowatts is billed at 10% above the basic rate. Above 500, billing is 25% above the basic rate. These surcharges apply only to the usage falling within the respective rate zone.

View Replies View Related

Create Array / Store 5 Objects And Calculate Total Price - VAT Rate

May 6, 2014

How can I do the work below in Java

In this main class, create 5 objects of the class Menu, as defined in the table below.

Name amount of calories cooking time price per person number of drinks

Fufu and Groundnut Soup 564.65 2515.572
Red Red 345 12 9.980
Rice and Beef Stew 560.4 1512.651
Ga Kenkey and Fish 780 10 10.15 1
Banku and Tilapia 450.4 35 25.17 2

Exercise d
In your main class create an array of length 5, and store the 5 objects (Exercise c) into the array. You can use any name for your array.

From the array, use a loop to: Print the details of all the objects using the method you defined in Exercise b.

Exercise e
Use another loop to:
-Print only the name and cooking time of all the dishes that take less than 30 minutes to cook. Hint: you may use the getter methods for the name and cooking time attributes, and then, print these values (name, cooking time).

Exercise f
Use another loop to :
-Calculate and print the total price of all the objects (in the array).
-Calculate the total price of all the objects with VAT included for each dish (VAT rate is 17.5%).

Submission
-Create a folder with your index number as its name.
-Copy your Java Project folder into the created folder.
-Print a hard copy of your classes.
-Submit both soft copy and hard copy of your project

View Replies View Related

Array Of Grades - Tally How Many As And Bs

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

Averaging Grades Program Not Adding Grades

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

Saving Number Of Chart In Array To New Array

Jan 15, 2014

just started programming in Java. My goal in this part of code was to read out the first array, while saving the number of the chart in the array to a new array.

first question: is the code clean and the method correct?

2nd question: i get an error when i try to print the newInt Array for no apparent reason.

Java Code:

public class viereinsdiezweite {
public static void main(String[] args){
int[] newInt = new int[20];
int specialInt = 3;
int[] bigInt = new int[]

[code]....

View Replies View Related

Program That Allows User To Enter Up To 10 Integer Grades Into Array

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

Calling Methods For Java GradeBook - Calculate Highest And Lowest Grades In Array

Apr 15, 2015

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;

[Code] ....

View Replies View Related

How To Pass Array To Method

Aug 3, 2014

So if I assigned values in arrays like the below:

This is the method in main class:

public static void trainer(){
trainer[] trainerArr = new trainer[4];
trainerArr[0] = new trainer("Ben Yap", "Male", "Kuala Lumpur", 10000, "Yoga");
trainerArr[1] = new trainer("Wilson Ting", "Male", "Kuala Lumpur", 10001, "Kick-boxing");

[Code] .....

How can i pass these arrays into another method in the main class?

View Replies View Related

Pass Array Data Between Methods

Feb 6, 2015

How do I pass the data within an initialized array from inside one method to another method of the same class? Will I need to return the array, assigning it to a temp array, which will then be passed as an argument to the other array? The idea is to create an array for an entire year, and be able to manipulate or edit data for a particular month using the other method.

public class Temperature {
static Scanner input = new Scanner(System.in);
static String [] monthArray = {"January", "February", "March", "April", "May",
"June", "July", "August", "October", "November", "December"};
public static void main(String[] args) {

[Code] .....

View Replies View Related

How To Pass Array From Servlet To JSP And Print

Dec 12, 2014

I'm trying to pass an integer array,

int[] fibSequence;

From my Fibonacci servlet to a jsp page called "result" but when I pass the array in the redirect I get the following output:

[[I@63cf2179]

I figured out that this is because the array is being converted to string before it is passed over and then converted again on the jsp page.

How I can pass the array over and print the contents, ie an array of integers?

This is how I'm sending the array in the result page:

resp.sendRedirect(("result.jsp?fibSequence=" + fibSequence));

And this is how its being retrieved and printed on the result.jsp page:

<%String[] fibSequence = request.getParameterValues("fibSequence");%>
<input type="text" name="fibNum" value="<%=java.util.Arrays.deepToString(fibSequence)%>" size="40px" style="font-size:30pt;height:60px">

View Replies View Related

Pass Predefined Size Array As Argument

Jan 9, 2014

Is this possible in Java?

public void doSomething(int[4] year){
}

What I am trying to do is to get the person who is using the method to send a year in the format 1998 and so on.

What would be the best way to accomplish this?

View Replies View Related

Unable To Pass A Two Dimensional Array To A Method

Sep 27, 2014

I have a question about an error I am getting when trying to pass a two dimensional array to a method. I keep getting the "incompatible types, int cannot be converted to int[][]". I am getting the error in a few different place (see comments - at the first call of the method, at a recursive call, and at the return statement. I believe I am passing the same type of array in all cases to the type of array defined in the method parameters.

Below is my code.

// this is a call from the main method
int[][] c = new int[temp1.length][temp1.length];
c = MatrixMultiply(a,b); // this is first place the error occurs
} // end main
public static int MatrixMultiply(int[][] A, int[][] B) {
// throw new UnsupportedOperationException("Not supported yet.");
int a[][] = A;

[Code]....

View Replies View Related

Trying To Pass Java Array To Method But It Is Not Working

May 5, 2015

***** start code ***

public class AddArray {
public static void main(String[] args) {
int sum = 0;
sum = addArray(myarray);
System.out.println(" hello");
System.out.println("This program will create an array then pass the array to an method to be totaled");
int myarray[] = new int [6];

[Code] ....

View Replies View Related

Pass User Input - Initializing Array In Method

Feb 7, 2015

I need to pass user input from the main method, which is then validated using another method that is returned as a valid score, and then I pass the valid input to another method that stores the data in an array. The array is initialized within the method. I tried to use an if-else statement to initialize the array, because I originally did this at the beginning of the method. I soon learned that I was creating a new array everything I accessed the method. Needless to say, this isn't working either.

public static void main(String[] args) {
int judges = 7;
float[] validScores = new float[judges];
for (int i = 0; i < judges; i++) {
float score = -1;

[Code] ....

View Replies View Related

JSP :: Pass Array From Servlet In Response To JavaScript Call?

Oct 16, 2014

I have an arraylist in my servlet which i need to pass to jsp as a response for a javascript call. This is an arraylist of DTOs. There are 24 DTO objects in the list. The DTO has an int variable and a HashMap. And i need to pass this into the javascript code in my jsp page. Do i use json? Do i send the entire list as a json object or should i iterate through the arraylist (from servlet) and serialize all the DTOs and pass that to the jsp?

View Replies View Related

Pass Objects From 3 Different Methods At Random To Different Class And Store In Array?

Jun 8, 2014

in my progrm there are three diff array of objects...namely garments..gadgets and home app...now one who buys from each of these sections will have to make a bill at last...when he choses to make the bill he will be shown the list of products he bought and their details (like price...brand...etc)...so i thought that while he orders each product(which is done in a previous method called purchase()...)....(each product is stored as an object in there diif arrays namely garments...gadgets ...appliances)....each of those object will be copied in a new array in a diif class...then that array print will give me the desired result...

is this approach correct...?and if its correct then how can i pull out a specific obj frm a stored array of object and then save it in a new array....?

View Replies View Related

Adding A Tick Rate To Game To Unlock FPS?

Nov 25, 2014

I need to add a tick rate so i can unlock the FPS. Here's the main render class/update class/game loop class.

Added back the formatting

Java Code:

package com.educodes.Main;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;

[Code] ....

View Replies View Related

Code Not Calculating Annual Sales Rate Correctly

Jul 19, 2014

My java code complies correctly runs and displays correctly but it is not calculating the annualSales * rate correctly.

/*
* The program will calculate annual salary and commission for a sales person.
* The user shall input the annual sales to calculate.
*/

package salescommission;

import java.util.Scanner;
public class SalesCommission {

[Code] ....

run:

The Salesperson earns a fixed annual salary of $10000.0.

Enter annual sales: 100000.00

The annual sales of the salesperson is $10000.0 using a 10% commission. (the is incorrect)

The total annual compensation of the salesperson is: $20000.0.

BUILD SUCCESSFUL (total time: 13 seconds)

View Replies View Related

Calculator Program - Print Heart Rate Ranges And User Information

Jan 26, 2014

I am attempting to make a heart rate calculator program. Here is a little overview of what I am trying to do. It must use a constructor and get and set methods. It must print heart rate ranges and the user's information(age).

// Use scanner to get inputs
import java.util.Scanner;
 
// Declare class
public class HeartRates {
private int Age;
private int DayOfBirth;
private int MonthOfBirth;
private int YearOfBirth;
private double MaxHeartRate;
private double MinTargetHeartRate;

[Code] ....

View Replies View Related

Write Class That Accepts User Hourly Rate Of Pay And Number Of Hours Worked

Feb 22, 2014

Here is what im trying to do

Write a class that accepts a user's hourly rate of pay and the number of hours worked. Display the user's gross pay (gross pay = hours worked * hourly rate), the tax withheld (tax withheld = gross pay * tax rate) and the net pay (net pay = gross pay - tax withheld).Use a named constant for storing the tax rate of 0.15

Here is my Code:
 
import java.util.Scanner;
 class Tutorial
{
public static void main(String[] args);

[Code]....

View Replies View Related

Student Class That Includes Boolean

Feb 7, 2015

Create an abstract class called Student. The Student class includes a name and a Boolean value representing full-time status. Include an abstract method to determine the tuition, with full-time students paying a flat fee of $2,000 and part-time students paying $200 per credit hour. Create two subclasses called FullTime and PartTime. Create an application that demonstrates how to create objects of both subclasses."

public abstract class Student {
private String name;
private int credits;
public Student(String name){
this.name = name;
credits =0;

[code]....

View Replies View Related

Student Grade Average Program?

Mar 27, 2015

I just have not got the chance to spend much time on it lately I know a bit but I'm not an expert or even intermediate with Java so I'm trying to make a program where the teacher enters the grade of each student and its stored in a variable the only problem is if I use a for loop the variable in which the result will be stired will be overwrite by the last repetition of the loop,I think the idea would be a nested loop but how I would go about using it in this situation,

here is my java code.

import java.util.Scanner;
class maths{
public static void main(String[] args)

[Code].....

View Replies View Related

Create A Student Class That Is Able To Search?

Mar 26, 2015

I want to create a Student class that is able to search, borrow, return, and reserve books. This is what I have done so far:

public class Student
{
private String username;

[Code].....

I think that I might need an array where to remember all of the books that the student has borrowed, but I'm not sure how to do that as well.

View Replies View Related

How To Develop Student Information Page On Web

Oct 3, 2014

Below mentioned table which show data on WEB page, thereof i need to develop page for my practice, steps to develop this like as following.

1.Tool Required to develop
2.Connectivity JDBC
  
create table student
(ROLLNO   NUMBER,
NAME     VARCHAR2(20),
DOB      DATE,
REG_DATE DATE,
ADDRESS  VARCHAR2(100),
PIC      LONG
)
 
INSERT INTO STUDENT VALUES(1,'ALI',TO_DATE('01-JAN-1982'),SYSDATE,'','');
INSERT INTO STUDENT VALUES(2,'JHON',TO_DATE('01-JAN-1985'),SYSDATE,'','');
INSERT INTO STUDENT VALUES(3,'CHARLI',TO_DATE('01-JAN-1990'),SYSDATE,'','');

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved