OrangeBaskets

OrangeBaskets - totalOranges = numberOfBaskets *...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 Ken Perry OrangeBasket Source Code import java.util.Scanner public class OrangeBasket { public static void main (String [] args) { int numberOfBaskets, orangesPerBasket, totalOranges, numberToRemove String YourName = "Ken Perry" numberToRemove = 6 Scanner keyboard = new Scanner (System.in) System.out.println ("Enter the number of oranges in each basket:") orangesPerBasket = keyboard.nextInt () System.out.println ("Enter the number of baskets:") numberOfBaskets = keyboard.nextInt () totalOranges = numberOfBaskets * orangesPerBasket System.out.println ("If " + YourName + " has") System.out.println (orangesPerBasket + " oranges per basket and") System.out.println (numberOfBaskets + " baskets, then") System.out.println ("the total number of oranges is " + totalOranges) System.out.println ("Now we take " + numberToRemove + " oranges out of $ orangesPerBasket = orangesPerBasket - numberToRemove
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: totalOranges = numberOfBaskets * orangesPerBasket System.out.println ("You now have") System.out.println (orangesPerBasket + " oranges per basket and") System.out.println (numberOfBaskets + " baskets.") System.out.println ("The new total number of oranges is " + totalOrange$ } } Compiling kperry@hermes:~$ time javac OrangeBasket.java real 0m0.820s user 0m0.390s sys 0m0.540s Running kperry@hermes:~$ time java OrangeBasket Enter the number of oranges in each basket: 12 Enter the number of baskets: 3 If Ken Perry has 12 oranges per basket and 3 baskets, then the total number of oranges is 36 Now we take 6 oranges out of each basket. Sheet1 Page 2 You now have 6 oranges per basket and 3 baskets. The new total number of oranges is 18 real 0m7.407s user 0m0.070s sys 0m0.110s...
View Full Document

Page1 / 2

OrangeBaskets - totalOranges = numberOfBaskets *...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online