This my problem>>>>if any one can solve it>>>

Write a java program that calculates and prints out bills of the city water company. The water rates vary, depending on whether the bill is for home use, commercial use, or industrial use. A code of 1 means home use, a code of 2 means commercial use, and a code of 3 means industrial use. Any other code should be treated as an error. The water rates are computed as follows:
• Code 1: Dh 5.00 plus Dh 0.005 per gallon use
• Code 2: Dh 1000.00 for the first 4 million gallons used and Dh 0.0025 for each additional gallon
• Code 3: Dh 1000.00 if usage doesn’t exceed 4 million gallons; Dh 2000.00 if usage is more than 4 million gallons but doesn’t exceed 10 million gallons; and Dh 3000.00 if usage exceeds 10 million gallons.
Your program should prompt the user to enter the number of customers (type int), an account number (type int), the code (type int), and the gallons of water used (type double). Your program should print the input data and print the amount due for each customer. Also your program should find and print the total income of the company and the average bill amount of each type of customer.

Recommended Answers

All 4 Replies

You need to decide if you are going to store you data in a flat file or in a database. A database will be much simpler.

Yes, many here can solve it. But you need to show your attempt and ask a specific question. If you do, many people will be happy to help.

http://www.daniweb.com/forums/announcement9-2.html

my solution
Challenge

package Challenge;

import java.util.Scanner;


public class Main {


    public static void main(String[] args) {
        Scanner input =new Scanner(System.in);
        int n=0 ; //number of customer
        int a; //acount number
        int c; // code of type 1 2 3
        double gallons ; //gallons of water used
        int code1=5;
        double bill;
        double total=0;
        double total1 = 0;
        double total2 =0;
        double total3 =0;
        double h;
        int count=0;
        int count1=0;
        int count2=0;
        int count3=0;
        h=0.005;
        int i=1;
        double aver;
        System.out.print("Enter number of customer here pleas :");
        n=input.nextInt();

        while (i<=n) {
            System.out.print("Enter acount of customer here pleas :");
            a=input.nextInt();
            System.out.println("Enter code 1=home , 2=commercial ,3=industrial = ");
            c=input.nextInt();
            System.out.print("Enter gallons here pleas:");
            gallons=input.nextDouble();
            System.out.println ("customer #"+ i+ "acount #"+ a);
            if (c==1) {
                bill= c1 + gallons * 0.005;
                total1=total1+ bill;
                count1=count1+1;
                System.out.println ("water bill is"+bill);
            }

            else if (c == 2)
            {
                bill =1000.00 + gallons *0.0025;
                total2=total2+bill;
                count2=count2+1;

            } else if (c == 3)
                if (gallons<=4000000)
                {
                    bill=100000;
                    total3=total3+bill;
                    count3=count3+1;
                }
            else if ((gallons>4000000)||(gallons<10000000))
            {

                bill=200000;
                total3=total3+bill;
                count3=count3+1;
            }
                else if (gallons>10000000)
                {
                    bill =300000;
                    total3=total3+bill;
                    count3=count3+1;
                }

                            else
            {
                System.out.println("Error");
            }

            i++;
            }
            total=total1+total2+total3;
            count=count1+count2+count3;
            System.out.println("Total home=");
            System.out.println(total1);
            System.out.println("Total commercial =");
            System.out.println(total2);
            System.out.println("Total industrial =");
            System.out.println(total3);
            System.out.println("count");
            System.out.println(count);
            aver=total/count;
            System.out.println("Average:");
            System.out.println(aver);
       }




    }

You need to decide if you are going to store you data in a flat file or in a database. A database will be much simpler.

I see nothing in the spec that requires any long-term non-volatile data storage. You enter the input every time you run the program. When the program is over, the input data is gone and the output data is not stored. You have to do it all over again the next time you run the program.

To the OP: Please use code tags when posting code.

You need to tell us what the problem is. Does the code compile? Does it run? Does it run correctly? Does it prompt for input? Does it display output? Is the output correct? If not, what input did you use, what was the actual output, and what should it have been? People need details in order to help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.