0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

paiza 勉強記録【残り物の量】【Java】

Last updated at Posted at 2024-12-31

paizaでの勉強記録です。
今回は下記のレベルアップ問題集のCランク問題の「残り物の量」を実施しました。

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//        仕入れ量
        int purchaseQuantity = sc.nextInt();
//        生のまま売れた割合
        double saledRatioOfRaw = sc.nextDouble()/100;
//        惣菜にして売れた割合
        double saledRatioOfDishes = sc.nextDouble()/100;
//        生のまま売れた量(kg)
        double saledQuantitiyOfRaw = purchaseQuantity * saledRatioOfRaw;
//        惣菜にして売れた量(kg)
        double saledQuantitiyOfDishes = (purchaseQuantity - saledQuantitiyOfRaw) * saledRatioOfDishes; 
//        売れ残りの量(kg)
        double leftoverStock = purchaseQuantity - (saledQuantitiyOfRaw + saledQuantitiyOfDishes);
        
        System.out.println(leftoverStock);
        
        sc.close();
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?