URI-1038 Solve

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

Problem link: https://www.urionlinejudge.com.br/judge/en/problems/view/1038

Solution:

  • [tab]
    • C
      • #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);
        
        }
    • C++
      • #include <iostream>
        #include <iomanip>
        
        using namespace std;
        
        int main()
        {
         int t;
         float q;
        
         cin >> t >> q;
        
         if(t == 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;
        }
3/Technology/post-list
Name

Codeforces,53,Problem Solve,90,Programming Tricks,1,URI,37,
ltr
item
DorHubs: URI-1038 Solve
URI-1038 Solve
https://resources.urionlinejudge.com.br/gallery/images/problems/UOJ_1038_en.png
DorHubs
https://dorhubs.blogspot.com/2019/08/uri-1038-solve.html
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/2019/08/uri-1038-solve.html
true
9087637800571592252
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy