Saturday, August 25, 2018

DAY OLD BREAD

  • Problem Description

    A bakery sells loaves of bread for 185 rupees each. Day old bread is discounted by 60 percent. Write a program that begins by reading the number of loaves of day old bread being purchased from the user. 

    Then your program should display the regular price for the bread, the discount because it is a day old, and the total price. 

    All of the values should be displayed using two decimal places, and the decimal points in all of the numbers should be aligned when reasonable values are entered by the user.
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      int x,y,z,total;
      scanf("%d",&x);
      y=x*185;
      z=y*60/100;
      total=y-z;
      printf("Regular Price=%d\n",y);
      printf("Total Discount=%d\n",z);
      printf("Total Amount to be paid=%d",total);
    return 0;
    }
  • Test Case 1

    Input (stdin)
    15
    
    
    Expected Output
    Regular Price=2775
    
    Total Discount=1665
    
    Total Amount to be paid=1110
  • Test Case 2

    Input (stdin)
    25
    
    
    Expected Output
    Regular Price=4625
    
    Total Discount=2775
    
    Total Amount to be paid=1850

No comments:

Post a Comment