001-002-007
Variable Assignment: Shopping Total Calculation
Easy
Problem Description
Variable Assignment: Shopping Total Calculation
Learning Objective: Assign values to multiple variables and use them for calculations
Create a program that calculates the total amount when buying two items. When you input the price of each item, it calculates and displays the total.
Input
Line 1: Price of item A (integer, yen)
Line 2: Price of item B (integer, yen)
Output
================================
Receipt
================================
Item A: [priceA] yen
Item B: [priceB] yen
------------------------
Total: [total] yen
================================
Examples
Example 1: 500 and 300 yen Purchase
Input:
500
300
Output:
================================
Receipt
================================
Item A: 500 yen
Item B: 300 yen
------------------------
Total: 800 yen
================================
Example 2: 1200 and 800 yen Purchase
Input:
1200
800
Output:
================================
Receipt
================================
Item A: 1200 yen
Item B: 800 yen
------------------------
Total: 2000 yen
================================
Example 3: 0 and 100 yen Purchase
Input:
0
100
Output:
================================
Receipt
================================
Item A: 0 yen
Item B: 100 yen
------------------------
Total: 100 yen
================================
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up