Saturday, August 18, 2018

GIZMOS

  • Problem Description

    An online retailer sells two products: widgets and gizmos.

    Each widget weighs 75 grams and Each gizmo weighs 112 grams. 

    Write a program that reads the number of widgets and the number of gizmos in an order from the user. 

    Then your program should compute and display the total weight of the order.
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      int a,b,c,d;
      float e;
      scanf("%d%d",&a,&b);
      c=a*75;
      d=b*112;
      e=c+d;
      printf("widgets=%d",a); 
      printf("\ngizmo=%d",b); 
      printf("\nTotal weight=%.3f",e/1000);
      
      

    return 0;
    }
  • Test Case 1

    Input (stdin)
    28
    
    22
    
    
    Expected Output
    widgets=28
    
    gizmo=22
    
    Total weight=4.564
  • Test Case 2

    Input (stdin)
    54
    
    23
    
    
    Expected Output
    widgets=54
    
    gizmo=23
    
    Total weight=6.626

No comments:

Post a Comment