URI Online Judge | 1038 Snack (Solution)
Problem Link:
https://www.urionlinejudge.com.br/judge/en/problems/view/1038
Solution:
https://www.urionlinejudge.com.br/judge/en/problems/view/1038
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 a 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 Yis 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.
Sample Input | Sample Output |
3 2 | Total: R$ 10.00 |
4 3 | Total: R$ 6.00 |
2 3 | Total: R$ 13.50 |
#include<stdio.h>
int
main()
{
int
x,y;
scanf
(
"%d %d"
,&x,&y);
switch
(x)
{
case
1 :
printf
(
"Total: R$ %.2lf\n"
,y*4.0);
break
;
case
2 :
printf
(
"Total: R$ %.2lf\n"
,y*4.50);
break
;
case
3 :
printf
(
"Total: R$ %.2lf\n"
,y*5.0);
break
;
case
4 :
printf
(
"Total: R$ %.2lf\n"
,y*2.0);
break
;
case
5 :
printf
(
"Total: R$ %.2lf\n"
,y*1.50);
break
;
}
return
0;
}
Thanks
ReplyDeleteThanks
ReplyDeletethanks
ReplyDeletethank u verry much
ReplyDeleteswitch tuh double nye kj kre na
ReplyDelete