Lab Exercise : Write a program that print the final price of purchase at a store where everything costs exactly one dollar. Ask for the number of items purchased. Compute a sales tax of: 8 percent if the users purchase is less than $100 7.5 percent if the purchase is greater or equal to $100. Also if the purchase is over $500, give the customer an additional 10 percent after-tax discount. Print the purchase price, the amount of tax, the amount of the discount ($0.00 if no discount applies) and the total price. Output: Enter number of items purchased= 60 the purchase price= 60 $ the amount of tax= 4.8 $ the amount of the discount= 0.00$ the total price= 64.8 $ Enter number of items purchased= 510 the purchase price= 510$ the amount of tax= 38.25$ the amount of the discount= 54.82$ the total price= 493.42$ void main() { int i; float price,tax,d=0,TP; cout<<"enter the no. of items = "; cin>>i; price=i; if(price>0) { if(price<100) tax= price * .08; else tax= price * .075; if(price+tax>500) d=(price + tax)*10/100; TP=price+tax-d; cout<<“ the purchase price= "<<price<<'$'; cout<<"\n\n the amount of tax= "<<tax<<'$'; cout<<"\n\n the amount of the discount= "<<d<<'$'; cout<<"\n\n the total price= "<<TP<<'$'; } else { cout<<"wrong entry"; } getch(); } Exercise : Write a program that request the user’s language and then print a greeting in that language. Output: Engl. , Fren. , Ger. , Ital. , or Rus. ? (e,f,g,i,r):e Welcome Where the greeting will be: English="Welcome" France="Bon jour" Germany=“Guten" Italian=“Bon giorno" Russian="Dobre utre"; Other language=“Sorry, we don't speak your language"; Void main() { char language; cout<< "Engl. , Fren. , Ger. , Ital. , or Rus. ? (e,f,g,i,r): "; cin>>language; if (language=='e') cout<<"Welcome"; else if (language=='f') cout<<"Bon jour"; else if (language=='g') cout<<"Guten"; else if (language=='i') cout<<"Bon giorno"; else if (language=='r') cout<<"Dobre utre"; else cout<<"Sorry, we don't speak your language"; getch(); } Exercise : and write a c++ program that reads an integer number of two digits, then display each digit in a separate line after checking that the number consists of only two digits, otherwise display an appropriate message. output: Enter number of tow digits =13 3 1 Enter number of tow digits =684 Wrong Entry void main() { int num; cout<<"Please enter an integer number of two digits :"; cin>>num; if((num>=10) && (num<100)) { d1=num%10; d2=num/10; cout<<d1<<endl<<d2; } else cout<<“Wrong Entry"; getch(); } Exercise: Write a program that reads a six-digits integer and prints the sum of its six digits. Use the quotient operator ( / ) and the reminder operator (%) to extract the digits from the integer. Output: Enter a six-digit integer: 342571 The sum of the digits of 34257 is 22 void main() { int n ,sum ; cout<<" Enter a six-digit integer :"; cin>>n; sum = n%10 + (n/10)%10 + (n/100)%10 + (n/1000)%10 + (n/10000)%10 + n/100000 ; cout<<“ The sum of the digits of “<< n <<” is: “<< sum; getch(); } Exercise: Write a program that reads a character and determine if it is a vowel letter or not . vowel letters =(a , e , I , o , u) Output: ENTER any character: a a is a vowel letter. Output: ENTER any character: t t is not a vowel letter. void main() { char le; cout<<"ENTER any character:"; cin>>le; switch(le) { case 'a': case 'e': case 'i': case 'o': case 'u': cout<<le<<" is a vowel letter."; break; default : cout<<le<<" is not a vowel letter."; } getch(); } Exercise: Output: - Square (sq) - Cube (c) -Squareroot (sr) - power (p) ENTER YOUR CHIOCE: sq enter your number: 2 4 - Square (sq) - Cube (c) - Squareroot (sr) - power (p) ENTER YOUR CHIOCE: p enter tow numbers: 2 3 8 #include<iostream.h> #include<conio.h> #include<math.h> #include<stdio.h> void main() { char choice[3]; float x,y,z; cout<<"Square (sq)\n"; cout<<"Cube (c)\n"; cout<<"Squareroot (sr)\n"; cout<<"power (p)\n"; cout<<"ENTER YOUR CHIOCE:"; gets(choice); switch(choice[0]) { case 's': case 'S': switch(choice[1]) { case 'q': case 'Q':cout<<"enter your number:"; cin>>x; z=x*x; cout<<z; break; case 'r': case 'R': cout<<"enter your number:"; cin>>x; z=sqrt(x); cout<<z; break; default : cout<<"error in index[1]"; } break; case 'c': case 'C': cout<<"enter your number:"; cin>>x; z=x*x*x; cout<<z; break; case 'p': case 'P': cout<<"enter tow numbers:"; cin>>x>>y; z=pow(x,y); cout<<z; break; default : cout<<"error"; } getch(); }