Results 1 to 2 of 2
- 09-08-2010, 04:16 AM #1
Member
- Join Date
- Sep 2010
- Posts
- 21
- Rep Power
- 0
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. -
- 09-08-2010, 05:15 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Do not post the same question multiple times. Stick with a one.
Similar Threads
-
Math.random not zero
By rsvr in forum New To JavaReplies: 3Last Post: 02-28-2010, 01:57 AM -
Need help with math equation
By annabellastorm in forum New To JavaReplies: 4Last Post: 01-10-2010, 05:12 PM -
printing two smallest numbers from a series of numbers
By trofyscarz in forum New To JavaReplies: 2Last Post: 10-14-2008, 11:46 PM -
need help with math for a new program
By gotenks05 in forum New To JavaReplies: 13Last Post: 09-26-2008, 07:32 AM -
Math Class (ceil, floor, abs)
By Java Tip in forum Java TipReplies: 0Last Post: 12-13-2007, 09:21 AM


LinkBack URL
About LinkBacks

Bookmarks