Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Decoration {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- double priceBalloonsTotal=0;
- double priceFlowersTotal=0;
- double priceCandlesTotal=0;
- double priceRibbonsTotal=0;
- while (budget>0){
- String command=scanner.nextLine();
- double ribbonSum=0;
- double balloonsSum=0;
- double flowersSum=0;
- double candlesSum=0;
- int totalBalloonsCount=0;
- int totalCandlesCount=0;
- int totalFlowersCount=0;
- int totalRibbonsCount=0;
- if (command=="balloons"){
- int balloonsCount= Integer.parseInt(scanner.nextLine());
- balloonsSum=0.1*balloonsCount;
- priceBalloonsTotal+=balloonsSum;
- }else if (command=="flowers"){
- int flowersCount=Integer.parseInt(scanner.nextLine());
- flowersSum=1.5*flowersCount;
- priceFlowersTotal+=flowersSum;
- }else if (command=="candles"){
- int candlesCount=Integer.parseInt(scanner.nextLine());
- candlesSum=0.5*candlesCount;
- priceCandlesTotal+=candlesSum;
- }else if(command=="ribbon"){
- int ribbonMeters=Integer.parseInt(scanner.nextLine());
- ribbonSum=ribbonMeters*2;
- priceRibbonsTotal+=ribbonSum;
- }
- double total=priceBalloonsTotal+priceCandlesTotal+priceFlowersTotal+priceRibbonsTotal;
- budget-=total;
- if (command=="stop"){
- System.out.printf("Spend money: %f", total);
- System.out.printf("Money left: %f", budget);
- }
- }
- System.out.println("All money is spent!");
- System.out.println("Purchased decoration is %d balloons, %d m ribbon, %d flowers and %d candles.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement