Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners How to write a program count total prices
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Vincent Tat
How to write a program count total prices
0 Answer(s)      a year and 9 months ago
Posted in : Java Beginners


Hi. all
I've got a assignment to write a program that count total prices of 8 costumers.

First class
class PriceCalculator
{print("code sample");
    public void method(double quantity)
    {
    double result;
        if(quantity < 5)
        {
            result = 2.00*quantity;
            System.out.printf(" is: %s",result);
        }
        if(quantity >= 6 & quantity <= 10)
        {
            result = 2.00*quantity*95/100;
            System.out.printf(" is: %s",result);
        }
        if(quantity >= 11 & quantity<= 15)
        {
            result = 2.00*quantity*90/100;
            System.out.printf(" is: %s",result);
        }
        if(quantity >= 16 & quantity<= 20)
        {
            result = 2.00*quantity*85/100;
            System.out.printf(" is: %s",result);
        }
        if(quantity >20)
        {
            result = 2.00*quantity*80/100;
            System.out.printf(" is: %s",result);
        }
    }
}

Second class
import java.util.Scanner;
public class PriceCalculatorTest{
    public static void main(String[] args){
        double enterQ;
        System.out.println("*****WELCOMETO PRICE CALCULATOR FOR PURCHANGSING MILKS*****");
        for(int counter = 1; counter <=8; ++counter)
        {
        Scanner input = new Scanner(System.in);
        PriceCalculator m = new PriceCalculator();
        System.out.printf("Enter the Name for Customer %s: ",counter);
        String name = input.nextLine();
        System.out.printf("Enter the number of cartons for Customer %s: ",counter);
        enterQ = input.nextInt();
        System.out.printf("The price for Customer - %s",name);
        m.method(enterQ);
        System.out.println();
        System.out.println("-------------------------------------------");

        }

    }
}

The problem is I'm being absolutely stuck in count total prices of 8 costumers like in this picture
![alt text][1]


  [1]: [IMG]http://i241.photobucket.com/albums/ff33/vanvi_1987/Untitled.jpg[/IMG]

Is there anyone,please help me..
Really thanks a lot

Advertisement
View Answers

Related Tutorials/Questions & Answers:
How to write a program count total prices
How to write a program count total prices  Hi. all I've got a assignment to write a program that count total prices of 8 costumers. class PriceCalculator{ public void method(double quantity) { double result
How to write a program count total prices
How to write a program count total prices  Hi. all I've got a assignment to write a program that count total prices of 8 costumers. First class... stuck in count total prices of 8 costumers like in this picture ![alt text][1
Advertisements
Java program to generate the total count
Java program to generate the total count  I need a java program which would take a text file as an input and scans through it to generate the output. For Ex. : If the text file contains the following information: There is/are 3
Modify the sales tax program to accept an arbitrary number of prices, total them, calculate the sales tax and print the total amount.
Modify the sales tax program to accept an arbitrary number of prices, total them, calculate the sales tax and print the total amount.  Modify the sales tax program to accept an arbitrary number of prices, total them, calculate
how to write this program
how to write this program  Write a program in java which calculates... + Class2Hours *Class2GPA +â?¦ +Class6hours * Class6GPA) / Total Hours For this program... or numerical grade. You will be submitting TWO versions of this program. Write one
How to write Java Program
How to write Java Program  how to write a program to find average of 5 student marks
program to print total marks
program to print total marks  program to input total marks out of 600 marks as an argument and print the stream allotted using the following criteria 401 & above - PCM 301-400 - ZBC 201-300- Commerce 101-200 - Arts
how to write servlet program in eclipse?
how to write servlet program in eclipse?  how to write servlet program in eclipse
How to write calculator in J2ME program?
How to write calculator in J2ME program?  How to write calculator in J2ME program
Write a query to find the total number of rows in a table
Write a query to find the total number of rows in a table  Write a query to find the total number of rows in a table?   Hi, Here is the answer, we can find the total number of rows in a table using following query
how to write this program? - Java Beginners
how to write this program?  (game:scissor,rock ,paper) A program that plays the sciccor-rock-paper game.Revise the program to let the user continuously play until either the user or the computer wins more than 4 times
how to write the program - Java Beginners
how to write the program  WAP to create the report card user input Name, Class, Division, Roll no., Marks obtained in following subjects Lang Hindi History Geography Math Phy Chem. Bio Eve CSTA Also has a back up
how to write a program to search a record using mvc2
how to write a program to search a record using mvc2   how can we write a code to search a record in table by using java bean as model, servlet as contoller and jsp as view
how do i write a java program for this??
how do i write a java program for this??  ??Ask the user if they have a dog. If ??yes??, ask the user how old is and compute the dog??s age... in your program
write a program
write a program  write a program add 2 no.s without use arithmetic,unary operaters in java
Find total disk space in PHP, php disk_total_space, disk_total_space
Learn How to Get the total disk space in PHP Program. In this PHP Tutorial example we will use the disk_total_space() function in our PHP code to find the total disk space. syntax disk_total_space() Function PHP disk_total_space
How to write program to show status of seats(i.e.free or reserve) in java?
How to write program to show status of seats(i.e.free or reserve) in java?  I have retrieved data from database table and I want to display status of seats i.e.free or reserved
how can i write this program ?please suggest me
how can i write this program ?please suggest me  Program to calculate the sum of two big numbers (the numbers can contain more than 1000 digits). Don't use any library classes or methods (BigInteger etc
How to Write a Calculator Program in Java?
How to Write a Calculator Program in Java? In this Java Tutorial you will learn how to write a Calculator program in Java in easy steps. Calculator program..., subtraction, multiplication or division. In this example of writing program in Java
how to write to java program to get the particular data from the website
how to write to java program to get the particular data from the website   i have to get the particular data by selecting the just numbers.. from the site .. how to get the ful details from the website by clicking the number
how to write a program in java to print numbers in equalateral triangle
how to write a program in java to print numbers in equalateral triangle  the output must be 1 324 76589   Here is an example of pattern 1 2 3 4 5 6 7 8 9 Example: public class NumberTriangle{ public
How do I write a program to manage an employee's business and personal contacts?
How do I write a program to manage an employee's business and personal contacts?  A. Input Requirements 1. Include a prompt that allows the user to enter a command from the following four options, repeating the process
Java Count Vowels
Java Count Vowels       In this program you will learn how to count vowels in a String. Here you... the number of vowels from that String. Description of the code: In the program code
Write a java application program........?
Write a java application program........?  Welcome every One : I have Q in Java? Q : Write a java application program that reads 20 integer numbers input by the user and prints how many numbers > 100 and how many numbers
write a java program
write a java program  write a program to print '*' in a circular form
WRITE A PROGRAM IN JAVA
WRITE A PROGRAM IN JAVA  Write program which accepts five students id,name,age,department,courses, taken and its grade. a. calculate its GPA . display all student information in ascending order
write the java program?
write the java program?  1 11 121 1331 14641 15101051
write the java program?
write the java program?  1 11 121 1331 14641 15101051
Write java program?
Write java program?  1 11 121 1331 14641 15101051
Write java program?
Write java program?  1 11 121 1331 14641 15101051
WRITE A PROGRAM IN JAVA
WRITE A PROGRAM IN JAVA  How do I write a program in Java, have the program display a message with your name in it and a number (Hello john Smith!1) The number must increment from zero to nine, or decrement fron nine to zero. You
 

 

 

DMCA.com