Cannot Get Average Program To Calculate Properly

May 9, 2010

I am having a problem with my program. I can't get my program to calculate properly. Everything compiles and run but its just giving me a wrong answer. I am suposse to get 115.50 but instead I am getting .30...

order.java
public class Order
{
double salesTaxRate; //initializing a variable for the sales tax rate.
double subTotal; //initializing a varliable for the sub total.
double shippingCost; //initializing a variable for shipping cost.
double salesTax; //initializing a variable for sales tax.
double totalCost; // initializing a variable for totale cost.

[Code] ....

View Replies


ADVERTISEMENT

Parallel Program - Calculate SUM And AVERAGE Of Odd Number Digits Between 25 And 75

Jun 11, 2014

You are to write a parallel program that will receive a large array of unsorted integers containing digits from 0 to 99. The program will have to calculate the SUM and AVERAGE of ODD number digits between 25 and 75 (inclusive). The user may specify the size or the array and the total processor that the machine has. The size of the array must be divisible by number of processor. Based on the given size, the computer will generate random integer numbers automatically to populate the array.

The program should display the status of the calculation for each processor. The result should be displayed after all calculations are completed.Error messages should be displayed appropriately

a) Write a sequential (non-parallel) program that will accomplish above task.
b) Write a concurrent (parallel) program that will produce the result of the above task.

View Replies View Related

Make A Program To Calculate Average Temperature And Annual Precipitation In Jacksonville

Oct 4, 2014

I wasn't supposed to use the % in front of f.I have to make a program to calculate the average temperature and annual precipitation in Jacksonville. I get this error on line 49:

java.util.IllegalFormatPrecisionException;
null (in java.util.Formatter$FormatSpecifier)

I don't get any errors during compilation.Here is my code (I'm not using the system selection yet):

import java.util.Scanner;
public class AnnualClimate1
{
public static void main(String[] args)
{
double[] temperaturesInJacksonville = {53.1, 55.8, 61.6, 66.6, 73.4, 79.1, 81.6, 80.8, 77.8, 69.4, 61.7, 55.0};

[code]....

View Replies View Related

Program That Takes In Family Members Calculate Family Average Age And Prints Out AI

Mar 9, 2014

I am to design a program in java that will allow a user to Input a list of your family members along with their age and state where they reside. Determine and print the average age of your family and print the names of anyone who live in Texas. I have tried but my results are wrong.

View Replies View Related

Calculate Least Common Multiple - Why Windowsbuilder Form Does Not Work Properly

Jan 31, 2015

I have done one program, that calculates the Least Common Multiple. The idea is to use WindowsBuilder on Ecplise in order to run it in a separate window. But when I started nothing happens. The code is:

import java.awt.BorderLayout;
import java.awt.EventQueue; 
import java.unit.Scanner;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

[Code] ....

Just wondering what could I do to make it happen. One thing came up on my mind - this is that need to connect the button with the function of the method, but still not sure will work.

View Replies View Related

Calculate SUM And AVERAGE Of ODD Number Digits Between 25 And 75

Jun 19, 2014

You are to write a parallel program that will receive a large array of unsorted integers containing digits from 0 to 99. The program will have to calculate the SUM and AVERAGE of ODD number digits between 25 and 75 (inclusive).

The user may specify the size or the array and the total processor that the machine has. The size of the array must be divisible by number of processor. Based on the given size, the computer will generate random integer numbers automatically to populate the array.

The program should display the status of the calculation for each processor. The result should be displayed after all calculations are completed.Error messages should be displayed appropriately

a) Write a sequential (non-parallel) program that will accomplish above task.
b) Write a concurrent (parallel) program that will produce the result of the above task.

View Replies View Related

Simulate Airport - Calculate Average Time A Plane Stays Inside A Queue For

Nov 13, 2014

Write a program to simulate this airport's operation. You might assume a simulated clock that advances in one-minute intervals. For each minute, generate two random numbers: If the first in less than LandingTime /60, a "landing arrival" has occurred and is added to the landing queue, and if the second is less than TakeOffTime /60, a "takeoff arrival" has occurred and is added to the takeoff queue.

Next, check whether the runway is free. If it is, first check whether the landing queue is nonempty, and if so, allow the first plane to land; otherwise, consider the takeoff queue. Have the program calculate the average queue length and the average time that an airplane spends in a queue.

I have most of the code done as you can see below:

* Queue Interface: Queue.java
* Queue Implementation: ArrayQueue.java
* Demo Program: Airport.java

Right now, I am stuck on the first calculation which is trying to figure out the average size of the landing queue. For some reason, as you can see at the bottom of my demo program, the average always comes out to be 0.0 and I'm not sure what's wrong.

Secondly, how to calculate the average time a plane stays inside a queue for.

View Replies View Related

Prompts User To Enter 5 Test Scores And Their Names - Calculate And Display Average

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

Using HasNext Properly In Program

Apr 16, 2015

Why do I get an error on the hasNext line when I try to compile this?

public static void main(String args[]) throws Exception
{
BufferedReader infile = new BufferedReader(new FileReader( "woodchuck.txt" ));
HashMap<String, Integer> histoMap = new HashMap<String,Integer>();
String word;
while((infile.hasNext()) !=null) {
if(histoMap.get(word)==null)
histoMap.put(word,1);
else
histoMap.put(word, histoMap.get(word)+1);
}
infile.close();
System.out.print(histoMap);

View Replies View Related

Program Won't Scan Properly The Text

Nov 19, 2014

I was trying to do a short program that scans a text for a given word and then tells you how many times that word was repeated in the text. The result was this:

var text = prompt("Write the text to be searched through");
var word = prompt("Write the word to be looked for. Beware of capitals!");
var hits = [];
for (var i = 0; i < text.length; i++) {
if (text[i] === word[0]) {

[Code] ....

However, this doesn't scan the text properly. I think the problem lies in one of the lines from 4 to 8, but, even after thinking quite a lot, I couldn't understand what was it. I thought that by saying that the letter of the text in position [i + k] shuold be equal to the letter of the word in position [k] I could make it work, but it doesn't.

View Replies View Related

Program Not Moving To The Next Line Properly?

May 14, 2014

I am trying to only allow the user to input numbers. But I need to enter a number twice before it moves to the next line statement and also skips a line when i enter th number a second time.

How can I go around fixing this.

My code for this is

case 1:
do{
Event event = new Event();
out.println("Please Enter the name.");
event.setEvent(input.next());
input.nextLine();

[Code]...

View Replies View Related

GPA And Average Program

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

Program That Has Weighted Average Code

Sep 28, 2014

I am doing a program that has a weighted average calculation and everything compiles and runs. It is just that my weighted average seems to be calculating incorrectly.This is the type of output I should see:

Homework:
Number of assignments? 3
Assignment 1 score and max? 14 15
Assignment 2 score and max? 16 20
Assignment 3 score and max? 19 25
Sections attended? 4
Total points = 65 / 80
Weighted score = 40.63
Exam 1:
Score? 81
Curve? 0
Total points = 81 / 100
Weighted score = 16.2
Exam 2:
Score? 95
Curve? 10
Total points = 100 / 100
Weighted score = 30.0
Course grade = 86.83

Below is my code and I think even after getting up this morning and looking at it, I have an error in the calculations, but I can;t pinpoint it.This program is supposed to receive input from user, and calculated the grades of a student with a weighted average
 
import java.util.Scanner;
public class Grades{
private double weightExam;
private double score;
private double curveAmount;
private double scoreTotal;

[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

Average Program - Number Format

May 5, 2015

I am writing a program using a given test drive... I am supposed to write two classes according to the test drive. The calculated correct answer should be 115.50 but i keep getting 115.52 instead and i just can't figure out what i'm doing wrong.

Here is the test drive code:

import java.text.NumberFormat;
public class FinalTester
{
public static void main(String[] args)
{
double avgPurchase;
Order[] lastYear = new Order[4];

[Code] ....

View Replies View Related

How To Write A Program Which Compensate Average

Jan 12, 2015

I have a question. How to write a progamme which compensates an average if it is less than a 10/20. I use eclipse and database HSQLDB. I have a table with notes. After the compensates, I must change the note in my database.

I have three notes

12, 11, 5

The average is 12+11+5/3=9,33

I take the lowest note: 5

12+11+x/3 = 10

12+11+x/3 = 30/3

x=30-23

x=7

The new average is 12+11+7/3=10

View Replies View Related

Test Score Average Program In Java

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

Trying To Create A Program That Provides Average Test Scores

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

Average Program - Divisible Numbers Not Calculating Correctly

May 21, 2015

For some reason, the averages aren't calculating correctly. I'm aware I need to convert to double if I'm dividing by an odd amount but that itself isn't the issue. It's just simple easy divisible numbers that are not being calculated correctly. For instance, (10 + 10 + 10 + 50) / 4 = should be 2 but I get 10.

Here is the code:

import java.util.Scanner;
public class Avg {
public static void main(String[] args){
Scanner inputGains = new Scanner(System.in);
int userInput = inputGains.nextInt();

[Code] ....

View Replies View Related

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 View Related

Writing A Pizza Program - Average Cost Of Order

Oct 9, 2014

I'm trying to write a program that will output the total number of large,medium,and small pizza along with the average cost of an order. I'm stuck on this error , "Else without if" on line 48 else ...medium.

import java.util.Scanner;
public class PizzaOrder
{
public static void main(String[] args)
{
Scanner input = new Scanner (System.in);
double cost,total, average;
String name,response,size,type;
int count,l,m,s;

[code]....

View Replies View Related

Grade Average Program - Hit Button Reseved For Calculations

Nov 23, 2014

I have written a simple grade average program. This is my code:

package programs;
 import java.util.Scanner;
 public class GradeAverage {
 public static void main(String[] args) {
 Scanner input = new Scanner(System.in);
int number;
int counter = 0;
int grade;
 
[Code] ....

Now the program is working just fine but what I don't like about it is the fact that you have to enter the number of grades before entering the grades. What I would prefer is to write your grades, hit some button that is reserved for calculating the average and then get the output.

View Replies View Related

Program Should Exit Repetition Loop And Compute And Display Average Of Valid Grades Entered

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

Java Program Using Nested Loop To Compute / Display Average Of Test Results For Each Experiment

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

How Does Program Know To Calculate For Only One Year

Mar 26, 2015

how does the program know to calculate for only one year?

public class Interest2 {
public static void main(String[] args) {
double principal; // The value of the investment.
double rate; // The annual interest rate.
double interest; // The interest earned during the year.

[code]....

View Replies View Related

Create A Program That Will Calculate Different Tax Brackets

Oct 3, 2014

I have spent the past 12 hours on it and have gotten no where. I need to create a program that will calculate different tax brackets. I have tried all combinations I can think of and can't get it to work!!! I am literally about to go insane! I need the program to calculate tax will be 1% for anything up to $50000. If the tax is over $50000, you keep that 1% of $50000 and then add the remaining. So for an income in the second range, it would be 1% of $50000, and then 2% of (income - $50000). This then continues for each range.

The problem I'm having is getting it to display the correct interest rates. I am not asking for you to write it for me. I want to learn. But at this point I have exhausted all resources available to me.

import java.util.Scanner;
public class Project3taxinfo {
public static void main(String[] args) {
final double RATE1 = 0.01; //1% tax on the first $50,000
final double RATE2 = 0.02; //2% tax on the amount over $50,000 up to $75,000
final double RATE3 = 0.03; //3% tax on the amount over $75,000 up to $100,000
final double RATE4 = 0.04; //4% tax on the amount over $100,000 up to $250,000
final double RATE5 = 0.05; //5% tax on the amount over $250,000 up to $500,000
final double RATE6 = 0.06; //6% tax on the amount over $500,000

[code]....

View Replies View Related







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