Algorithm


Problem Name: beecrowd | 1038
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1038

Snack

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Using the following table, write a program that reads a code and the amount of an item. After, print the value to pay. This is a very simple program with the only intention of practice of selection commands.

Input

The input file contains two integer numbers X and Y. X is the product code and Y is the quantity of this item according to the above table.

Output

The output must be a message "Total: R$ " followed by the total value to be paid, with 2 digits after the decimal point.

Input Sample Output Sample

3 2

Total: R$ 10.00

 

4 3

Total: R$ 6.00

 

2 3

Total: R$ 13.50

 

Code Examples

#1 Code Example with C Programming

Code - C Programming



#include<stdio.h>
int main()
{
    int X, Y;
    float price = 0;

    scanf("%d %d", &X, &Y);
    if (X == 1)
    {
        price  = (float) (4.00 * Y);
    }
    else if (X == 2)
    {
        price  = (float) (4.50 * Y);
    }
    else if (X == 3)
    {
        price  = (float) (5.00 * Y);
    }
    else if (X == 4)
    {
        price  = (float) (2.00 * Y);
    }
    else if (X == 5)
    {
        price  = (float) (1.50 * Y);
    }

    printf("Total: R$ %.2f\n",price);

}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 2

Output

x
+
cmd
Total: R$ 10.00

#2 Code Example with C++ Programming

Code - C++ Programming



#include<iostream>
#include<iomanip>

using namespace std;

int main(){
    int t;
    float q;

    cin>>t>>q;
    if(x==1){
        q *= 4.0;
    }else if(t==2){
        q *= 4.5;
    }else if(t==3){
        q *= 5.0;
    }else if(t==4){
        q *= 2.0;
    }else {
        q *= 1.5;
    }
    cout<<"Total: R$" << setprecision(2) << fixed <<q << endl;

return 0;
    
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
4 3

Output

x
+
cmd
Total: R$ 6.00

#3 Code Example with Java Programming

Code - Java Programming



import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        int X, Y;
        float price = 0;

        Scanner input = new Scanner(System.in);
        X = input.nextInt();
        Y = input.nextInt();
        
        if (X == 1) {
            price = (float) (4.00 * Y);
        } else if (X == 2) {
            price = (float) (4.50 * Y);;
        } else if (X == 3) {
            price = (float) (5.00 * Y);
        } else if (X == 4) {
            price = (float) (2.00 * Y);
        } else if (X == 5) {
            price = (float) (1.50 * Y);
        }

        System.out.printf("Total: R$ %.2f\n",price);
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
2 3

Output

x
+
cmd
Total: R$ 13.50

#4 Code Example with Python Programming

Code - Python Programming



X,Y=list(map(int,input().split()))
if(X == 1):
    price  = (float) (4.00 * Y)
elif(X == 2):
    price  = (float) (4.50 * Y)
elif(X == 3):
    price  = (float) (5.00 * Y)
elif (X == 4):
    price  = (float) (2.00 * Y);
elif (X == 5):
    price  = (float) (1.50 * Y)
print(f"Total: R$ {price:.2f}")
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 2

Output

x
+
cmd
Total: R$ 10.00

#5 Code Example with Another Python Programming

Code - Python Programming



X,Y = map(int,input().split())
Item = {1:4.0,2:4.5,3:5.0,4:2.0,5:1.5}
X = float(Item[X])*Y
print(f"Total: R$ {X:.2f}")
Copy The Code & Try With Live Editor

Input

x
+
cmd
4 3

Output

x
+
cmd
Total: R$ 6.00
Advertisements

Demonstration


Previous
#1037 Beecrowd Online Judge Solution 1037 Interval Solution in C, C++, Java, Python and C#
Next
#1040 Beecrowd Online Judge Solution 1040 Average 3- Solution in C, C++, Java, Python and C#