I am working on trying to show the average daily sales for the store. I cannot quite figure out why my calculation is not working. Everything works except my average sales is always $0.00... lines 185-189 is where my calculation is located.
Java Code:
import java.util.*;
import java.text.*;
import javax.swing.JOptionPane;
/*******************************************************************************
* Create a fancy class for a cash register.
*******************************************************************************/
public class fancyRegister{
/** current amount due */
private double currentAmount;
i have to ask user gross sales until -1 sentinial and to get the commission to put in groups its 9% times the sales add $200 the groups are formatted a) $200-299 /> $300-399 .... i) $1000 and over
import java.util.Scanner; public class Commissions { /** * @param args
Design a program that will read a file of sales records and produce a sales report. Each record in the file contains a customer's ID, name, a sales amount, and a validated GST code. The GST code is to be applied to the sales amount to determine the sales tax due for that sale, as shown below.
GST CodeGST Rate 0 1 20% 5% 10%
The report is to print a heading "SALES REPORT", and detail lines listing the customer's ID, name, sales amount, sales tax, and total amount due including sales tax.
Is assignment sofar:pseudo code SalesReport Read customer file Get TaxCode Get GSTAmount SalesTax Calculate SalesTax
{ public static void main (String []args) { Scanner numberin = new Scanner (System.in); double store [];
[Code]....
How would I get my program to display a * for every 100 dollars in sales that the user enters in so: for example the user enters in store 1: $ 400 in sales for the store I want it to display store 1:****
The first part of my code allows the user to enter in whatever values the stores have in sales. The Second half of the code starts at line 19 is my best guess on what I need to do I just am not sure how to get it to display what I need it to.
import java.io.*; public class workhours{ public static void main (String args[]){ try{ BufferedReader breader=new BufferedReader(new InputStreamReader(System.in)); String days[]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
Hospital management system in java. I have designed Hospital, Doctor, Patient, Appointment classes. I am able to add doctor list and patient list and show the doctor list and patient list. How to take new appointment from a patient and assign it to a particular doctor and how to generate a report for inpatient and outpatient on a daily basis.
my project is to design a class that stores the number of units sold and has a method that returns the total cost of the purchase..the given info is unit are $99. discounts are 20% for 10-19 units; 30% for 20-49 units; 40% for 50-99 units; and 50% for 100 or more units purchased... When i run the code and put in the units sold it returns: 0 units sold, $0.00 cost, 0% discount. How do I get the output to actually do the equation and give proper information. We were given a demo file from the instructor and had to create a class that works with it first set of code is the demo file:
package chapter4; import java.text.DecimalFormat; import java.util.Scanner; /** * SoftwareSalesDemo Program */ public class SoftwareSalesDemo { public static void main(String[] args) { int units; // To hold units sold
I have this small program that creates a sales opportunity and its related products, and then prints out the opportunity name, total quantity and total price
class Opportunity{ String name; int Amount; String Stage; int Product_quantity;
[Code] .....
The code works as expected, and is successfully prints :
That said, I feel the way the OpportunityCreator class sums up the quantities and prices (see the comments on the code) is very inefficient, and would only work if there were 3 or less products. How can I design this so that it sums the quantities and prices of all the Product objects that I create, regardless of how many of them are? I understand probably I'd need to redesign the whole thing but I'd like to get at least an idea of how this can be achieved.
Originally I was thinking of creating an ArrayList and adding all the prices/quantities there but wasn't sure how to do. I also thought of using a loop to loop through the different object references and sum the quantity/price but was also unsure on how to do so?
The manager of a football stadium wants you to write a program that calculates the total ticket sales after each game. There are four types of tickets: box, sideline, premium, and general admission. After each game, the data is stored in a file in the following format:
ticketPrice numberOfTicketsSold
Sample data might look like:
250 5750
100 28000
50 35750
25 18750
The first line indicates that the box ticket price is $250 and that 5750 tickets were sold at that price.
Your program should input in this data (using Scanner or an input dialog box), then output that data to a message dialog box along with total ticket sales information. Output the total number of tickets sold and the total sale amount. Make your output user-friendly and "pretty". Format your output with two decimal places. Use JOptionPane and the formatting techniques learned in chapter 3 for your output. Example output might be:
5750 Box Tickets sold at $250.00 28000 Sideline Tickets sold at $100.00 35750 Premium Tickets sold at $50.00 18750 General Admission tickets sold at $25.00
gather sales amount for the week display the total of sales display the average of sale display the highest sale amount display the lowest sale amount
using occurrences determine how many times the amount occurred for the week
make a sales main make a sales data
This is what i have so far but I'm confused on how to start the occurrence and where it would be placed in order to get the information from the array
public class SalesData { private double[] sales; // The sales data /** The constructor copies the elements in an array to the sales array. @param s The array to copy. */ public SalesData(double[] s) {
I'm writing this super simple code as I follow along in this java textbook, and I don't know why it's giving me an error in my tester program!
CashRegister.java
public class CashRegister //a cash register totals up sales and computes change due { private double purchase; private double payment; /**establishes instance variables "purchase" and "payment" and assigns them as doubles to store the two amounts later on. the assignment as private makes it so ONLY methods in this class can access these instance variables*/
This specific assignment requires me to write a program that calculates the total sales after each football game. There are 4 types of tickets: box, sideline, premium, and general admission. After each game, data is stored in a file... then output the number of tickets sold and total sale amount. Format your output with 2 decimal places.
Okay I know there is a I/O section and wasnt sure where to post this. I need some insight on how to use file input and output as well ... Here is my program:
import javax.swing.JOptionPane; import java.text.DecimalFormat; public class ticketsSold { public static void main(String[] args) { String BoxSeat; String SideLine;
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;
In the class, you will have three instance variables,
1) array to hold the numbers, 2) the odd average, and 3) the even average.
The constructor should accept as input the array from the tester class and assign it to the instance variable. You should then have a method, findAverage, that will read the array and then calculate the average of the even input values and the average of the odd input values. (Hint: You can use % (mod) to determine if a number is even or odd). Your program will need a getOddAverage and a getEvenAverage method.
public class oddEvenAverage { int [] myArray = new int[10]; public double oddAverage; public double evenAverage; public oddEvenAverage(int number){ int myArray = number;
[Code] .....
What am i doing wrong here? I can't get it working!
I'm trying to calculate the average of grades that a user puts in. Here is my code so far:
public static void main(String[] args) { Scanner input = new Scanner (System.in); System.out.println("Please enter an array of grades seperated bt a comma."); input.nextLine(); String arrayOfGrades = "100,50,100"; String[] grades = arrayOfGrades.split(",");
[Code] .....
I think I'm on the right track, the only big error I'm really getting is the line: sum += grades[i]. It's saying string can not be converted into a double.
I am trying to write a code that asks the user to enter a temperature for each day of the week and then it prints out the high temperature, the low temperature, and the average temperature. This is the code I have so far:
import java.util.*; import java.text.DecimalFormat; public class Lab10 { public static void main(String[] args) { java.util.Scanner input = new java.util.Scanner(System.in); int high, low, i, sum; double avg; [Code] ....
There are a few issues that I am having.
1. I can't for the life of me figure out how to make it print the low temperature 2. I had it running perfectly until I changed one thing and now I get a compile error saying that the last 5 statements are unreachable. (lines 32-37)
How to create a simple program that can input number from 1 to n. and display the numbers which input by the user and also display the sum and average of it.
Ex. Please input a number: 1 2 3 4 5 6 7 8 9 10
the sum numbers of 12345678910 is 55 the average number of 12345678910 is ______,
For my project, I am trying to return the method average so the program can calculate the average after grades are enter. I'm not sure what I am doing wrong and how I should improve it. My code is below. This is my error message: "Project.java:71: error: '.class' expected".
import java.util.Scanner; public class Project { public static void main(String[] args)
I have make a simple grade average project and can't figure out how to ask the user if they want to enter more grades to average and run the app again.Here's what I have so far.
import java.util.Scanner; public class Average { private static Scanner kb; public static void main(String[] args) { kb = new Scanner(System.in);
This program will not give me the average high temperature for the week and I cannot figure out why! Every time it only spits out "0" whereas the average low temperature works great..
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Temps_Grid_Keenan extends JFrame { private static final long serialVersionUID = 1L; private static final int WIDTH = 400; private static final int HEIGHT = 500;
I am trying to do the following java assignment and every thing seems to work fine except when I put a number<4 or >10 it prints both "Invalid grade!"
"You didn't enter any data!" what I wanted is to print only "Invalid grade!" I tried to fix it but I couldn't.
Create a program that asks for results of exams and calculates the mean average of the grades. Grades are floating point numbers between 4 and 10. Program asks for grades until a negative number is typed. If user gives a grade other than a number between 4 and 10, the text "Invalid grade!" will be printed on screen and program asks for another grade. Finally the program prints the number of inputted grades and their mean average on screen as shown in the example print. If no grades were inputted, the notice "You did not input any grades." is the only thing printed on screen.
A double type variable is to be used to store the value of the average.
Program is written to a class called Average.
Example output
Program calculates the average of inputted grades.
Finish with a negative integer.
Input a grade (4-10): 5 Input a grade (4-10): 6,5 Input a grade (4-10): 7,5 Input a grade (4-10): 7 Input a grade (4-10): 0 Invalid grade! Input a grade (4-10): -4 4 grades inputted. Average of the grades: 6.5
Java Code:
import java.util.Scanner; public class apples { public static void main(String[] args) int inputNumber=0; int sum; int count; double average;