Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
import java.util.Scanner; /** * Created by entropy on 5/1/2017. */ public class cakes { public static void main(String[] args) { Scanner scanner = new Scanner (System.in); // The number n – amount of cakes Ivancho wants. //• The number c – kilograms of flour needed to make one cake. //• The number f – kilograms of flour available. //• The number t – amount of truffles available. //• The number p – price of one truffle. int cakesWanted=Integer.parseInt(scanner.nextLine()); double flourNeededPerCake=Double.parseDouble(scanner.nextLine()); int kgFloorAvailable=Integer.parseInt(scanner.nextLine()); int trufflesAvailable=Integer.parseInt(scanner.nextLine()); int trufflePrice=Integer.parseInt(scanner.nextLine()); double maxFlour=cakesWanted*flourNeededPerCake; //if flour is not enough if (maxFlour>kgFloorAvailable){ double numberOfCakes=kgFloorAvailable/flourNeededPerCake; double diffFlour=flourNeededPerCake*cakesWanted-kgFloorAvailable; System.out.print("Can make only "+(int)numberOfCakes+" cakes, need "); System.out.printf("%.2f",diffFlour); System.out.println(" kg more flour"); //if floor is enough } else{ double productionCost=trufflesAvailable*trufflePrice; double cakePrice=(productionCost/cakesWanted)*1.25; System.out.print("All products available, price of a cake: "); System.out.printf("%.2f",cakePrice); } } }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)