Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Java coding for writing telephone bill calculator program

  1. #1
    Junior Member
    Join Date
    Sep 2009
    Thanked 0 Times in 0 Posts

    Default Java coding for writing telephone bill calculator program

    ou were hired or a programmer by a telephone company employs metering scheme in computing the telephone bill. the metering scheme is as follow

    call made on weekday between 6:00AM to 6:00PM are charged at 2.50 dollar per minute charged at are charged weekday are charged a discount rate of 2.00 dollars per minute. calls made anytime on weekend are charged a weekend rate of 1.50 dollar per minute. your job is to write a program that will ask the user to enter the ff. information: an integer representing the day so on an integer representing (in 24 hours format) the call started; and an integer representing the time the call ended

    please guys if you think the rate are ridiculous please did is not real life rate just a java problem and not real please here my code but i do not how to put the 2.50 discount rate im really lose please kindly help me where to put this codes please could kindly help me to understand this im confused and also please could also tweak or could please kindly finish what is missing in my code and this not and assignments or homework its just a SEAT-WORK i did im really confused at it

    import java.util.Scanner;
     class week {
        public static double weekendRate = 1.5;
        public static double weekRate = 2;
        public static void main(String[] args) {
            int day;
            int startHour;
            int startMinute;
            int endHour;
            int endMinute;
            int begin;
            int end;
            int duration;
            double bill;
            Scanner in = new Scanner(System.in);
            System.out.print("What is the weekday?");
            day = in.nextInt();
            System.out.print("What is the starting time? Hour:");
            startHour = in.nextInt();
            System.out.print(" Minute: ");
            startMinute = in.nextInt();
            System.out.print("What is the ending time? Hour:");
            endHour = in.nextInt();
            System.out.print("Minute: ");
            endMinute = in.nextInt();
            begin = startHour * 60 + startMinute;
            end = endHour * 60 + endMinute;
            duration = end - begin;
            if (day == 6 || day == 7) {
                 bill = duration * weekendRate;
            } else {
            bill = duration * weekRate;
            System.out.println("Duration: " + duration + " minutes");
            System.out.println("Bill: " + bill + " dollar ");
    Last edited by Freaky Chris; September 8th, 2009 at 04:44 AM. Reason: Added code tags

  2. #2
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    My Mood
    Thanked 105 Times in 90 Posts

    Default Re: kindly help me with this miss java problem

    I cannot make sense of this, it doesn't read logically at all. I mean the problem not the code btw.


  3. #3
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Thanked 619 Times in 561 Posts
    Blog Entries

    Default Re: kindly help me with this miss java problem

    I think this is what he meant:

    calls between 6:00am and 6:00pm on weekdays are $2.50/min
    other calls on weekdays are $2.00/min
    calls on weekends are $1.50/min

    the program needs to ask for the day, the start time of the call, and the end tome of the call, and compute how much the call should be charged.

    Personally, I wouldn't use integers to represent which day of the week it is. It's not the most user friendly method, and can get quite confusing to program with, especially on team projects.

    Here's what I'd do for representing the day:
    public static enum DayOfWeek {
    		public String toString()
    			if (this == MONDAY)
    				return "Monday";
    			else if (this == TUESDAY)
    				return "Tuesday";
    			else if (this == WEDNESDAY)
    				return "Wednesday";
    			else if (this == THURSDAY)
    				return "Thursday";
    			else if (this == FRIDAY)
    				return "Friday";
    			else if (this == SATURDAY)
    				return "Saturday";
    				return "Sunday";
    		public boolean isWeekend()
    			if (this != SATURDAY && this != SUNDAY)
    				return false;
    				return true;

Similar Threads

  1. java. Text problem...
    By Ranger-Man in forum Java SE APIs
    Replies: 8
    Last Post: September 7th, 2009, 07:19 PM
  2. java problem
    By Mj Shine in forum Java Theory & Questions
    Replies: 1
    Last Post: August 14th, 2009, 12:24 AM
  3. Java session problem
    By Padmaja in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: August 5th, 2009, 09:06 PM
  4. Java GUI problem in paintComponent?
    By Richard_ in forum AWT / Java Swing
    Replies: 2
    Last Post: May 1st, 2009, 08:19 AM
  5. [SOLVED] JAVA JList Problem in visual images
    By antitru5t in forum AWT / Java Swing
    Replies: 4
    Last Post: April 15th, 2009, 03:09 PM