Results 1 to 2 of 2
  1. #1
    Allspark is offline Member
    Join Date
    Sep 2010
    Posts
    21
    Rep Power
    0

    Default Roundind up numbers using Math.ceil

    I'm writing a simple program for my Java fundamentals class and I was instructed to round up the results using the Math.ceil () method but I have not been able to successfully incorporate it into my code. Tips?



    // Program helps student determine how many pizza and soda should
    // be purchased for student activities.

    import java.util.Scanner;

    public class PizzaSoda
    {
    public static void main(String[] args)
    {
    int People;
    double Hours;
    double Pizza = .4;
    double Soda = .25;
    double Result, Value;


    Scanner keyboard = new Scanner(System.in);

    System.out.print("Enter the number of people expected to attend this activity: ");
    People = keyboard.nextInt();

    System.out.print("Enter the duration of the activity in hours: ");
    Hours = keyboard.nextDouble();

    System.out.println((Pizza * People) + " whole pizzas will be needed.");
    System.out.println((Soda * People * Hours) / 2 + " 2-liter bottles of soda will be needed.");

    System.exit(0);
    }

    }
    - Winners compare their achievements with their goals, while losers compare their achievements with those of other people. -

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Math.random not zero
    By rsvr in forum New To Java
    Replies: 3
    Last Post: 02-28-2010, 01:57 AM
  2. Need help with math equation
    By annabellastorm in forum New To Java
    Replies: 4
    Last Post: 01-10-2010, 05:12 PM
  3. printing two smallest numbers from a series of numbers
    By trofyscarz in forum New To Java
    Replies: 2
    Last Post: 10-14-2008, 11:46 PM
  4. need help with math for a new program
    By gotenks05 in forum New To Java
    Replies: 13
    Last Post: 09-26-2008, 07:32 AM
  5. Math Class (ceil, floor, abs)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-13-2007, 09:21 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •