#include <stdio.h> // 3 points int main() { int x; printf("Enter a value for x >"); scanf("%d",&x); if(x >= 6 ) { if(x < 10){ if(x > 7) Value of x Program output printf("A"); typed by else user printf("C"); 15 }else{ if ( x > 12) 7 printf("D"); else 3 printf("B"); } } else printf("F"); return 0; } (b-2) #include <stdio.h> // 3 points int main() { int y; scanf("%d",&y); switch(y){ Value of y Program output case 7: y=y+1; typed by user case 3: y=y+2; 7 break; case 2: y=y+3; 2 default: y=y+4; } 4 printf("%d\n",y); return 0; } Question # 3 [15 points] Assume that a bookstore gives 5% discount in case that your total purchasing amount is more than SR100; otherwise no discount will be given. Consider the problem of computing the final net price given the total purchasing amount, state and apply the first 4 steps of the software development method to solve it.
#include <stdio.h> // 3 points int main() { int x; printf("Enter a value for x >"); scanf("%d",&x); if(x >= 6 ) { if(x < 10){ Value of x typed by user Program output 15 7 3 if(x > 7) printf("A"); else printf("C"); }else{ if ( x > 12) printf("D"); else printf("B"); } } else printf("F"); return 0; } (b-2) #include <stdio.h> // 3 points int main() { int y; scanf("%d",&y); Value of y typed by user Program output 7 2 4 switch(y){ case 7: y=y+1; case 3: y=y+2; break; case 2: y=y+3; default: y=y+4; } printf("%d\n",y); return 0; } Question # 3 [15 points] Assume that a bookstore gives 5% discount in case that your total purchasing amount is more than SR100; otherwise no discount will be given. Consider the problem of computing the final net price given the total purchasing amount, state and apply the first 4 steps of the software development method to solve it.
ICS103-midterm-141.docx