0% found this document useful (0 votes)
7 views8 pages

CPP Assignment

The document contains three programming assignments submitted by Adil Amin for a BSCS course. The first assignment is a scholarship eligibility checker using nested if-else statements, the second is a taxation system using if-else statements, and the third is a hospital billing system using switch and nested if-else statements. Each assignment includes code snippets and outlines the expected outputs for various scenarios.

Uploaded by

khokhar1234555
Copyright
© All Rights Reserved
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)
7 views8 pages

CPP Assignment

The document contains three programming assignments submitted by Adil Amin for a BSCS course. The first assignment is a scholarship eligibility checker using nested if-else statements, the second is a taxation system using if-else statements, and the third is a hospital billing system using switch and nested if-else statements. Each assignment includes code snippets and outlines the expected outputs for various scenarios.

Uploaded by

khokhar1234555
Copyright
© All Rights Reserved
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

ASSIGNMENT

SUBMITTED BY :
ADIL AMIN
ROLL NO #22

SUBMITTED TO :
PROF. MUHAMMAD IMRAN

DEPARTMENT :
BSCS

SEMESTER :
1ST (Evening)
(2024-2028)

Q1. Scholarship Eligibility Checker(nested if-else)


#include<iostream>
using namespace std;
int main()
{
float gpa;
double income=0;
cout<<"Enter your GPA :";//input GPA
cin>>gpa;
cout<<"Enter your total family income :";//input income
cin>>income;
if(gpa>=3.5&&income<75000)//eligible OR not eligible
{
if(gpa>3.8 && income<50000)//eligiblr for full OR partial scholarship
{
cout<<"YOU ARE ELIGIBLE FOR FULL SCHOLARSHIP";
}
else
cout<<"YOU ARE ELIUGIBLE FOR PARTIAL SCHOLARSHIP";
}
else
cout<<"YOU ARE NOT ELIGIBLE FOR SCHOLARSHIP";

return 0;}
OUTPUT Q1;
When user eligible for full scholarship.
When user eligible for partial scholarship.

When user not eligible for scholarship

Another case for not eligible for scholarship

[Link] System(if-else)
#include <iostream>

using namespace std;

int main()
{

double income=0; //required variables

double tax=0;

cout<<"Enter your total income :";//input income for tax

cin>>income;

if(income>0&&income<=50000) //'if' to calculate tax for income <= to 50000

cout<<"Tax = "<<tax;

else

if(income>50000&&income<=100000) //'if' to calculate tax for income <= to 100000

income=income-50000;

tax=income*10.0/100.0;

cout<<"tax = "<<tax;

else

if(income>100000&&income<=200000)//'if' to calculate tax for income <= to 200000

income=income-100000;

tax=income*20.0/100.0+5000;

cout<<"tax = "<<tax;

else

if(income>200000) //'if' to calculate income above 200000

income=income-200000;

tax=income*30.0/100.0+25000;

cout<<"tax = "<<tax;

else

cout<<"INVALID INCOME"; //if user enter invalid income

return 0; //end

output q2.
[Link] handle invalid income
[Link] on income less than $50000

[Link] on incone between $50000 and $100000

[Link] on income between $100000 and $200000

[Link] on income that above $$200000

[Link] BILLING SYSTEM


(switch&nested if-else)
#include<iostream>
using namespace std;

int main() //main function

{ char pt{1}; //required variables

double bill=0;

int test=0;

int day=0;

int dctrc=0;

//input patient type

cout<<"Enter patient type\'Inpatient OR Outpatient\' :";

cin>>pt;

switch(pt) //handle patient type with switch statement

case 'i': //case one for "inpatient"

case 'I':

cout<<"Enter number of days in hospital :";

cin>>day; //inpuy days

if(day>0) //'if else' to find patient type

cout<<"Enter number of test conducted :";

cin>>test; //input test

if(test>0)

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

cin>>dctrc; //input no. of consulation

if(dctrc>0)

bill=(day*500)+(200*test)+(dctrc*100)+50;

else

bill=(day*500)+(200*test)+50;

else

{ //execute only if day>0&&test=0

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

cin>>dctrc;

if(dctrc>0)

bill=(day*500)+(200*test)+(dctrc*100)+50;

else

bill=(day*500)+(200*test)+50;

else

cout<<"You are not inpatient"<<endl;


break;

case 'o': //case outpatient

case 'O':

cout<<"Enter number of test conducted :";

cin>>test;

if(test>0)

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

cin>>dctrc;

if(dctrc>0)

bill=(300*test)+(dctrc*150)+50;

else

bill=(300*test)+50;

else //execute only if test=0

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

cin>>dctrc;

if(dctrc>0)

bill=(dctrc*150)+50;

else

bill=(300*test)+50;

break;

cout<<"Your total bill is :$"<<bill;//total bill

return 0;

}
Output q3.
1.

You might also like