0% found this document useful (0 votes)
28 views4 pages

การบ้านวิชา 662304 Information Technology Lab 1: #include #include using namespace void int void int void int void int

The document is a code sample in C++ that defines functions to analyze numbers. It takes a number as input, then calls functions to check if the number is odd, even, or prime. It outputs the results. There is also a second code sample that calculates VAT and total costs for multiple products. It takes product names, prices, and amounts as input, applies a 7% VAT to each price, and outputs a table with the results.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views4 pages

การบ้านวิชา 662304 Information Technology Lab 1: #include #include using namespace void int void int void int void int

The document is a code sample in C++ that defines functions to analyze numbers. It takes a number as input, then calls functions to check if the number is odd, even, or prime. It outputs the results. There is also a second code sample that calculates VAT and total costs for multiple products. It takes product names, prices, and amounts as input, applies a 7% VAT to each price, and outputs a table with the results.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

662304 Information Technology Lab 1

#include <iostream> #include<string> using namespace std; void OddNumber(int n); void EvenNumber(int n); void PrimeNumber(int n); void main() { int select,num; cout << "\t***************" << endl; cout << "\tMENU of Program" << endl; cout << "\t1.Input Number" << endl; cout << "\t2.Exit Program" << endl; cout << "\t***************" << endl; cout << "\tYou Select : "; cin >> select; if(select==1){ cout << "\tThe Number is : "; cin >> num; if(num>=9999){ cout << "\tThe Number is } if(num<=0) { cout << "\tThe Number is } if(num>=0&&num<=9999) { OddNumber(num); EvenNumber(num); PrimeNumber(num); } } if(select==2){ cout << "\t***Exit Program*** " } } void OddNumber(int n) { if(n%2!=0) { cout << "\tThe Number " << n << } } void EvenNumber(int n) { if(n%2==0) { cout << "\tThe Number " << n << }

More please input again." << endl;

Less please input again." << endl ;

<< endl;

" is OddNumber ";

" is EvenNumber ";

} void PrimeNumber(int n) { int check=0; for(int i=2;i<n;i++) if(n%i == 0){ check++; } if(check == 0 && n != 1) cout << " and PrimeNumber" <<endl; }

5.

#include<iostream> #include<string> using namespace std; float vat(float price); float total(float price, int amount); int main() { string product1,product2,product3; float price1,price2,price3; int amount1,amount2,amount3; cout << "Enter Product Name : "; cin >> product1; cout << "Enter Price per Amount : "; cin >> price1; cout << "Enter Amount : "; cin >> amount1; cout << "Enter Product Name : "; cin >> product2; cout << "Enter Price per Amount : "; cin >> price2; cout << "Enter Amount : "; cin >> amount2; cout << "Enter Product Name : "; cin >> product3; cout << "Enter Price per Amount : "; cin >> price3; cout << "Enter Amount : "; cin >> amount3; cout << endl; cout <<" No. Product Price/Amount Vat 7% Include Vat Amount Total"<<endl; cout <<" 1 "<<product1 << " " << price1 << " " << vat(price1) ; cout << " " << price1+vat(price1) << " " << amount1 << " " <<total(price1,amount1) << endl; cout <<" 2 "<<product2 << " " << price2 << " " << vat(price2) ; cout << " " << price1+vat(price2) << " " << amount2 << " " <<total(price2,amount2) << endl; cout <<" 3 "<<product3 << " " << price3 << " " << vat(price3) ; cout << " " << price1+vat(price3) << " " << amount3 << " " <<total(price3,amount3) << endl; cout <<" total "; cout <<total(price1,amount1)+total(price2,amount2)+total(price3,amount3)<<endl; return(0); } float vat(float price) { return(price*7/100); } float total(float price,int amount)

{ float vat; vat=price*7/100; return((vat+price)*amount); }

You might also like