Monday, May 30, 2016

URI Online Judge Solution 1038 || Snack

URI Online Judge | 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 and Yis the product code and 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 SampleOutput Sample
3 2Total: R$ 10.00
4 3Total: R$ 6.00
2 3Total: R$ 13.50

URI Online Judge Solution 1038 || Snack in Java language


import java.io.IOException;
import java.util.Scanner;
  
/**
 * IMPORTANT:
 *      O nome da classe deve ser "Main" para que a sua solução execute
 *      Class name must be "Main" for your solution to execute
 *      El nombre de la clase debe ser "Main" para que su solución ejecutar
 */
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);
  
    }
  
}




Download code from Dropbox
Question link in URI



No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.