netjunky

KatjaJu

Oct 17th, 2010
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main( int argc, char **argv ) {
  5.  
  6.     double S, H, K;
  7.     int A;
  8.     char V;
  9.    
  10.     /* Operation sisestada S */
  11.     printf("Raha summa = ");
  12.     scanf("%lf", &S);
  13.     V = '+';
  14.    
  15.     while( S > 0 && V == '+' ) {
  16.    
  17.         printf ("Kauba artikkel = ");
  18.         scanf("%d", &A);
  19.        
  20.         do {
  21.        
  22.             printf("Kauba hind (positiivne) = ");
  23.             scanf("%lf", &H);
  24.            
  25.         } while( H < 0 );
  26.        
  27.         do {
  28.        
  29.             printf("Kauba kogus (positiivne) = ");
  30.             scanf("%lf", &K);
  31.            
  32.         } while( K < 0 );
  33.        
  34.         if( H * K <= S ) {
  35.        
  36.             S -= H * K;
  37.             printf("Kaup on ostetud. Teil jäi %8.2lf EEK.\n", S);
  38.            
  39.         } else {
  40.        
  41.             printf("Raha jäi puudu.\n");
  42.            
  43.         }
  44.    
  45.         printf("Kas soovite jätkata? '+' või '-' ");
  46.         scanf("%c", &V);
  47.     }
  48.    
  49.     printf("Külastage meid jälle!");
  50.     //scanf("%c",&V);
  51.     //scanf("%c",&V);
  52.    
  53.     return 0;
  54. }
Add Comment
Please, Sign In to add comment