Challenge 5: Box Totals! 🚀
Welcome to this challenge! Work with Robo 🤖 to solve this problem step-by-step using algorithms and flowcharts.
🎬 The Story
There are $3$ chocolates in a box, and Robo has $4$ boxes. Help Robo read two numbers, multiply them, and display the total number of chocolates.
📝 The Algorithm
- Start (Begin)
- Read Number1 and Number2 (Input)
- Multiply Number1 and Number2 and store in
product(Process) - Display product (Output)
- Stop (End)
📊 The Flowchart
💻 From Flowchart to Code
Here is how to multiply two input numbers in Python, Java, and C:
- Python
- Java
- C
# Read two numbers
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
# Multiply
product = num1 * num2
# Display result
print("Product:", product)
import java.util.Scanner;
public class MultiplyNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter first number: ");
int num1 = sc.nextInt();
System.out.print("Enter second number: ");
int num2 = sc.nextInt();
// Calculate product
int product = num1 * num2;
System.out.println("Product: " + product);
}
}
#include <stdio.h>
int main() {
int num1, num2, product;
printf("Enter first number: ");
scanf("%d", &num1);
printf("Enter second number: ");
scanf("%d", &num2);
// Calculate product
product = num1 * num2;
printf("Product: %d\n", product);
return 0;
}