Wednesday, December 2, 2015

Uri problem 1038 solve

Problem :

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 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.
Sample InputSample Output
3 2Total: R$ 10.00
4 3Total: R$ 6.00
2 3Total: R$ 13.50

Solution:


#include <stdio.h>
  
int main() {
  
    int X , Y, Z;
  float total;
  scanf("%d %d",&X,&Y);
  if(X == 1 )
  {
      total=4*Y;
      printf("Total: R$ %.2f\n",total);
  }
  else if(X == 2)
  {
      total=4.50*Y;
      printf("Total: R$ %.2f\n",total);
  }
  else if (X==3)
  {
      total=5.00*Y;
      printf("Total: R$ %.2f\n",total);
  }
  else if (X== 4)
  {
      total=2.00*Y;
      printf("Total: R$ %.2f\n",total);
  }
  else if (X == 5)
  {
      total =1.5*Y;
      printf("Total: R$ %.2f\n",total);
  }
  
    return 0;
}

No comments:

Post a Comment