flower Sale

flower Sale - if(in.hasNextInt()) { unit = in.nextInt(); }...

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

View Full Document Right Arrow Icon
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package flowersale; import java.util.*; /** * * @author Manny */ public class FlowerSale { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner in = new Scanner(System.in); String isContinue = "yes"; String flower = ""; double total = 0; int unit = 0; double TULIP_UNIT_PRICE = 0.99; double ROSE_UNTIL_PRICE = 1.5; double CARN_UNIT_PRICE = 0.99; while (isContinue.equalsIgnoreCase("yes")) { System.out.println("What flower do you prefer? (Tulip, Rose,Carnation: "); flower = in.next(); System.out.println("How many flowers you will purchase? ");
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: if(in.hasNextInt()) { unit = in.nextInt(); } else { System.out.println("Wrong input, please start over."); System.exit(0); } if(flower.equalsIgnoreCase("tulip")) { total=total+(TULIP_UNIT_PRICE*unit); } else if(flower.equalsIgnoreCase("rose")) { total=total+(ROSE_UNTIL_PRICE*unit); } else if(flower.equalsIgnoreCase("carnation")) { total=total+(CARN_UNIT_PRICE*unit); } else { System.out.println("Wrong input, please start over."); System.exit(0); } System.out.println("Continue? (yes/no):"); isContinue = in.next(); } //output System.out.printf("Total price is $%,.2f\n",total); } }...
View Full Document

This note was uploaded on 12/07/2011 for the course BUS 350 taught by Professor Leighjin during the Fall '11 term at S.F. State.

Page1 / 2

flower Sale - if(in.hasNextInt()) { unit = in.nextInt(); }...

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