You are on page 1of 9

//NADIAH 2016209116

//LAB 2- C1-q1-1 (page11)

#include<iostream>

using namespace std;


int main()
{
//variables
int a1,a2,sum,minus,times,div,mod;

//input
cout<<"please insert the first value : ";
cin>>a1;
cout<<"please insert the second value : ";
cin>>a2;

//process
sum=a1+a2;
times=a1*a2;
minus=a1-a2;
mod=a1 % a2;
div=a1/a2;

//output
cout<<a1<< " + " <<a2<< " = "<<sum<<endl;
cout<<a1<< " - " <<a2<< " = "<<minus<<endl;
cout<<a1<< " x " <<a2<< " = "<<times<<endl;
cout<<a1<< " / " <<a2<< " = "<<div<<endl;
cout<<"remainder of "<<a1<< " / " <<a2<< " = "<<mod;
}
//NADIAH 2016209116
//LAB 2- C1-q2 (page11)

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
float m1,m2,m3,m4,m5,sum,avg;

//input
cout<<"please insert the marks : ";
cin>>m1;
cout<<"please insert the marks : ";
cin>>m2;
cout<<"please insert the marks : ";
cin>>m3;
cout<<"please insert the marks : ";
cin>>m4;
cout<<"please insert the marks : ";
cin>>m5;

//process
sum=m1+m2+m3+m4+m5;
avg=sum/5;

//output
cout<<"total marks of 5 students is " <<sum<<endl;
cout<<"average marks of 5 students is " <<fixed<<setprecision(2)<<avg;
}
//NADIAH 2016209116
//LAB 2- C1-q3 (page11)

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{

{
//3a

//variables
float f,c;

//input1
cout<<"please insert the value of fahrenheit : ";
cin>>f;

//process1
c=(f-32)*5/9;

//output1
cout<<f<<" fahrenheit = " <<fixed<<setprecision(2)<<c<<" celcius"<<endl<<endl<<endl;
}

{
//3b
//variables
float metre,inch;

//input
cout<<"please insert the value in metre : ";
cin>>metre;

//process
inch=metre*39.3701;

//output
cout<<metre<<" metre = " <<fixed<<setprecision(2)<<inch<<" inch"<<endl<<endl<<endl;
}

{
//3c
//variables
float km,m;
//input
cout<<"please insert the value in kilometer : ";
cin>>km;

//process
m=km*1000;

//output
cout<<km<<" kilometer = " <<fixed<<setprecision(2)<<m<<" metre"<<endl<<endl<<endl;
}

{
//3d

//variables
int hr,min,sec,mod1,sec2;

//input
cout<<"please insert the value in seconds : ";
cin>>sec;

//process
hr=sec/3600;
mod1=sec%3600;
min=mod1/60;
sec2=mod1%60;
//output
cout<<sec<<" seconds = " <<endl;
cout<<hr<<" hour "<<endl;
cout<<min<<" minutes "<<endl;
cout<<sec2<<" seconds"<<endl<<endl<<endl;
}

{
//3e

//variables
int cents,fifty,twenty,ten,five,one,r1,r2,r3;

//input
cout<<"please insert the value in cents : ";
cin>>cents;

//process
fifty=cents/50;
r1=cents%50;
twenty=r1/20;
r2=r1%20;
ten=r2/10;
r3=r2%10;
five=r3/5;
one=r3%5;

//output
cout<<cents<<" cents = " <<endl;
cout<<fifty<<" fifty cent(s) "<<endl;
cout<<twenty<<" twenty cent(s) "<<endl;
cout<<ten<<" ten cent(s) "<<endl;
cout<<five<<" five cent(s) "<<endl;
cout<<one<<" one cent(s))"<<endl<<endl<<endl;
}
}
//NADIAH 2016209116
//LAB 2- C1-q4 (page11)
#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
//variables
int ilt,coke,lg,pz;
double pilt,pcoke,plg,ppz,total,gst,stax,total1,gtotal,terima,baki;

//input for quantity


cout<<"QUANTITY OF ICED LEMON TEA \t: ";
cin>>ilt;

cout<<"QUANTITY OF COCA COLA \t\t: ";


cin>>coke;

cout<<"QUANTITY OF LING GRANCHIO \t: ";


cin>>lg;

cout<<"QUANTITY OF PZ MARGHERITA \t: ";


cin>>pz;

//process
//counting prices, gst, service charge and grand total
pilt=ilt*4.60;
pcoke=coke*3.99;
plg=lg*25.00;
ppz=pz*20.00;
total=pilt+pcoke+plg+ppz;
stax=total*10/100;
total1=total+stax;
gst=total1*7/100;
gtotal=total+gst+stax;

//output grand total


cout<<"\nTOTAL\t\t\t\t: " <<fixed<<setprecision(2)<<gtotal<<endl;

//input amount cash given


cout<<"AMOUNT OF CASH GIVEN \t\t: ";
cin>>terima;

//process to calculate change


baki=terima-gtotal;

//output receipt
cout<<"\n\n\n\t\t\t ETNA \n\t\t Italian Restaurant & Pizzeria \n\t\t 110 UPPER EAST
COST ROAD \n\t\t SHAH ALAM 455289 \n\t\t TEL : 64449530 FAX : 64449553 \n\t\t GST REG
NO : 20-0517740-C \n\t\t www.ETNAitalianrestaurant.com \n";
cout<<"============================================================= \n";
cout<<"2/10/2017 \t 20:23 \t\t\t\t Bill: C12300 \nTable :12 A \t\t\t\t\t cashier: 008 \n";
cout<<"============================================================= \n";
cout<<setw(5)<<"Qty"<<endl;
cout<<setw(5)<<ilt<<setw(20)<<"ICED LEMON TEA"<<setw(35)<<pilt<<endl;
cout<<setw(5)<<coke<<setw(20)<<"COCA COLA"<<setw(35)<<pcoke<<endl;
cout<<setw(5)<<lg<<setw(20)<<"LING GRANCHIO"<<setw(35)<<plg<<endl;
cout<<setw(5)<<pz<<setw(20)<<"PZ MAGHERITA"<<setw(35)<<ppz<<endl<<endl;
cout<<setw(25)<<"SUBTOTAL"<<setw(35)<<total<<endl;
cout<<setw(25)<<"10% SERVICE
CHARGE"<<setw(35)<<fixed<<setprecision(2)<<stax<<endl;
cout<<setw(25)<<"7% GST"<<setw(35)<<gst<<fixed<<setprecision(2)<<endl;
cout<<"============================================================= \n";
cout<<setw(25)<<"TOTAL"<<setw(35)<<gtotal<<endl;
cout<<setw(25)<<"CASH"<<setw(35)<<terima<<endl;
cout<<setw(25)<<"CHANGE"<<setw(35)<<baki;

}
//NADIAH 2016209116
//LAB 2- C1-q5 (page12)

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
float gpa1,cgpa1,gpa2,cgpa2,sum1,sum2;
{
//SEMESTER 1
//varible
float m11,m12,m13,m14,m15,m16,tgp11,tgp12,tgp13,tgp14,tgp15,tgp16;

cout<<"********************RESULT FOR SEMESTER 1********************\n\n";


//input
cout<<"please enter grade point for CHM192 : ";
cin>>m11;
cout<<"please enter grade point for CSC198 : ";
cin>>m12;
cout<<"please enter grade point for CTU185 : ";
cin>>m13;
cout<<"please enter grade point for ELC180 : ";
cin>>m14;
cout<<"please enter grade point for MAT193 : ";
cin>>m15;
cout<<"please enter grade point for PHY194 : ";
cin>>m16;

//process
//calculate total grade point
tgp11=m11*5;
tgp12=m12*5;
tgp13=m13*2;
tgp14=m14*3;
tgp15=m15*5;
tgp16=m16*5;

//calculate gpa and cgpa


sum1=tgp11+tgp12+tgp13+tgp14+tgp15+tgp16;
gpa1=sum1/25;
cgpa1=gpa1;

//output
cout<<"\n\nGPA for semester 1 is " <<fixed<<setprecision(2)<<gpa1<<endl;
cout<<"CGPA for semester 1 is " <<cgpa1<<endl<<endl;
}
{
//semester 2
//variables
float m21,m22,m23,m24,m25,m26,tgp21,tgp22,tgp23,tgp24,tgp25,tgp26;

cout<<"********************RESULT FOR SEMESTER 2********************\n\n";


//input
cout<<"please enter grade point for CHM292 : ";
cin>>m21;
cout<<"please enter grade point for CSC298 : ";
cin>>m22;
cout<<"please enter grade point for CTU285 : ";
cin>>m23;
cout<<"please enter grade point for ELC280 : ";
cin>>m24;
cout<<"please enter grade point for MAT293 : ";
cin>>m25;
cout<<"please enter grade point for PHY294 : ";
cin>>m26;

//process
//calculate total grade point
tgp21=m21*5;
tgp22=m22*5;
tgp23=m23*2;
tgp24=m24*3;
tgp25=m25*5;
tgp26=m26*5;

//calculate gpa and cgpa


sum2=tgp21+tgp22+tgp23+tgp24+tgp25+tgp26;
gpa2=sum2/25;
cgpa2=(sum1+sum2)/50;

//output
cout<<"\nGPA for semester 1 is " <<fixed<<setprecision(2)<<gpa2<<endl;
cout<<"CGPA for semester 1 is " <<cgpa2<<endl<<endl;
}
}

You might also like