Psycology

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

GOVT POST GRADUATE COLLEGE MANDIAN

ABBOTTABAD

Submitted by: US M AN
Roll no: 207018
Department: Computer Science
Semester: 6th
Submitted to: SIR YASHIR
#include <iostream>
using namespace std;

int main ()
{
int choice;
{
cout<<"1) Display Alhamdulillah."<<endl;
cout<<"2) Display your Name and Registration No. on
Screen."<<endl;
cout<<"3) Take two number and arithmetic operator
from user and perform the arithmetic operation on
numbers."<<endl;
cout<<"4) Take three ages from user and display the
younger and older."<<endl;
cout<<"5) Take number from user and check whether it
is even or odd."<<endl;
cout<<"6) Give 15% discount if total bill exceeds from
1500."<<endl;
cout<<"7) Give 10% increment to employee if his/ her
year of service is greater than 5."<<endl;
cout<<"8) Grading System."<<endl;
cout<<"9) Input number of rows, columns, and symbol
from user and print the symbol."<<endl;
cout<<"10) Alphabet is vowel or consonant. "<<endl;
cout<<"11) Table with limit."<<endl;
cout<<"12) Fibonacci Series."<<endl;
cout<<"13) Exit."<<endl;

while (choice !=13)


{
cout<<"Enter your choice: ";
cin>>choice;

switch(choice)
{
case 1:
{
cout<<"ALHAMDULILLAH"<<endl;
break;
}
case 2:
{
string name, reg;

cout<<"Enter Your Name: ";


cin>>name;
cout<<"Your Name is "<<name<<endl;

cout<<"Enter Your Reg No: ";


cin>>reg;
cout<<"Your Reg No is "<<reg<<endl;
break;
}
case 3:
{
float x,y,ans;
char oper;
cout<<"Enter First Number: ";
cin>>x;
cout<<"Enter Second Number: ";
cin>>y;
cout<<"Arithmetic Operator: ";
cin>>oper;

switch(oper)
{
case '+':
ans=x+y;
break;
case '-':
ans=x-y;
break;
case '*':
ans=x*y;
break;
case '/':
if(x||y==0)
{
cout<<"Cannot divide by 0";
}
else
{
ans=x/y;
}
break;
default:
cout<<"Invalid Operator"<<endl;
return 0;
}
cout<<"Answer is : "<<x<<" "<<oper<<"
"<<y<<"="<<ans<<endl;
break;
}
case 4:
{
int age1,age2,age3;
cout<<"Enter Age: \n";
cin>>age1>>age2>>age3;

int young_age,old_age;
//for YOUNGEST
if (age1 <= age2 && age1 <= age3)
{
young_age = age1;
}
else if (age2 <= age1 && age2 <= age3)
{
young_age = age2;
}
else
{
young_age = age3;
}
//for OlDEST
if (age1 >= age2 && age1 >= age3)
{
old_age = age1;
}
else if (age2 >= age1 && age2 >= age3)
{
old_age = age2;
}
else
{
old_age = age3;
}

cout << "The youngest age is: " << young_age <<
endl;
cout << "The oldest age is: " << old_age << endl;

break;
}
case 5:
{
int x;
cout<<"Enter a Number: ";
cin>>x;
if(x%2==0)
{
cout<<"Number is Even";
}
else
{
cout<<"Number is Odd";
}
break;
}
case 6:
{
int x,y,z;
cout<<"Bill Amount: ";
cin>>x;
if(x>1500)
{
y=0.15*x;
cout<<"Discounted Bill: "<<y<<endl;
z=x-y;
}
else
{
z=x;
}
cout<<"Total Bill: "<<z<<endl;
break;
}
case 7:
{
float x,y,z;
cout<<"Salary: ";
cin>>x;
cout<<"Year of Service: ";
cin>>y;
if(y>5)
{
z=0.10*x;
z=x+z;
}
else
{
z=x;
}
cout<<"Incremented Salary: "<<z<<endl;
break;
}
case 8:
{
int a,b,c,d,avrg;
char grade;
cout<<"Maths: ";
cin>>a;
cout<<"Physics: ";
cin>>b;
cout<<"Chemistry: ";
cin>>c;
cout<<"Bio: ";
cin>>d;
avrg=(a+b+c+d)/4;

if(avrg>=80)
{
cout<<"Grade A";
}
else if(avrg>=70)
{
cout<<"Grade B";
}
else if(avrg>=60)
{
cout<<"Grade C";
}
else
{
cout<<"Fail";
}

break;
}
case 9:
{
int
rows,cols;
char symbol;

cout<<"Enter the number of rows: ";


cin>>rows;
cout<<"Enter the number of columns:
";
cin>>cols;
cout<<"Enter the symbol: ";
cin>>symbol;

for(int i = 0; i < rows; i++)


{
for(int j = 0; j < cols; j++)
{
cout<<" "<<symbol;
}
cout<<endl;
}
break;
}
case 10:
{
char
alpha;
cout<<"Enter a Alphabet:";
cin>> alpha;
if ((alpha == 'a')||(alpha == 'e')||
(alpha == 'i')||(alpha == 'o')||(alpha == 'u')||(alpha == 'A')||
(alpha == 'E')||(alpha == 'I')||(alpha == 'O')||(alpha == 'U'))
{
cout<<"Alphabet is Vowel";
}
else
{
cout<<"Alphabet is
Consonant";
}
break;
}
case 11:
{
int num, limit;

cout<< "Enter a number: ";


cin>> num;

cout<< "Enter the limit: ";


cin>> limit;

for(int i = 1; i <= limit; i++)


{
cout<< num << " x " << i << " = "
<< num * i << endl;
}

break;
}
case 12:
{
int num, first = 0, second = 1, next;
cout<< "Enter the number of terms: ";
cin>> num;

cout<< "Fibonacci Series: ";

for(int i = 0; i < num; i++)


{
if(i <= 1)
{
next = i;
}
else
{
next = first + second;
first = second;
second = next;
}
cout << next << " ";
}

break;
}
case 13:
{

cout<<"EXIT";

break;
}
default:
{

cout<<"Invalid Choice \n";


}
}
}
}
return 0;
}

OUTPUT

You might also like