0% found this document useful (0 votes)
6 views7 pages

AbdurRehman 2 G 350

The document contains three programming assignments related to Object-Oriented Programming (OOP) in C++. The first assignment involves creating a student record system that captures names, scores, and grades, while the second and third assignments focus on a restaurant menu system that calculates total costs and taxes based on user selections. Each assignment includes code snippets demonstrating the implementation of the specified functionalities.

Uploaded by

abdulre274
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)
6 views7 pages

AbdurRehman 2 G 350

The document contains three programming assignments related to Object-Oriented Programming (OOP) in C++. The first assignment involves creating a student record system that captures names, scores, and grades, while the second and third assignments focus on a restaurant menu system that calculates total costs and taxes based on user selections. Each assignment includes code snippets demonstrating the implementation of the specified functionalities.

Uploaded by

abdulre274
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
You are on page 1/ 7

ASSIGNMENT NO:1

OOP
Name: AbdurRehman Roll no:350-2G
Section: 2-G Teacher: MISS Misbha
Qusetion 1
#include <iostream>

#include <string>

using namespace std;

struct Student {

string name;

int score;

char grade;

};

int main() {

const int NUM_STUDENTS = 10;

Student students[NUM_STUDENTS];

for (int i = 0; i < NUM_STUDENTS; i++) {

cout << "Enter student " << i + 1 << "'s name: ";

cin >> students[i].name;

cout << "Enter student " << i + 1 << "'s score: ";

cin >> students[i].score;


if (students[i].score >= 90) {

students[i].grade = 'A';

} else if (students[i].score >= 80) {

students[i].grade = 'B';

} else {

students[i].grade = 'F';

int highestScore = students[0].score;

for (int i = 1; i < NUM_STUDENTS; i++) {

if (students[i].score > highestScore) {

highestScore = students[i].score;

cout << "\nStudents' Data:" << endl;

for (int i = 0; i < NUM_STUDENTS; i++) {

cout << "Name: " << students[i].name << ", Score: " << students[i].score << ", Grade: " <<
students[i].grade << endl;

cout << "\nHighest Score: " << highestScore << endl;

}
Question # 2

#include <iostream>
#include <string>

using namespace std;

struct menuItemType
{
string itemName;
double price;
};

int main()
{
menuItemType menu[] = {
{"Plain Egg", 1.45},
{"Bacon and Egg", 2.45},
{"Muffin", 0.99},
{"French Toast", 1.99},
{"Fruit Basket", 2.49},
{"Cereal", 0.69},
{"Coffee", 0.50},
{"Tea", 0.75}
};

cout << "Welcome to Our Restaurant" << endl;


for (int i = 0; i < 8; i++)
{
cout << i + 1 << ". " << menu[i].itemName << " $" << menu[i].price << endl;
}

double total = 0;
int choice;
while (true)
{
cout << "Enter your choice (1-8)"<<endl<<"Press 0 for bill : ";
cin >> choice;
if (choice == 0)
break;
total += menu[choice - 1].price;
}

double tax = total * 0.05;


double amountDue = total + tax;

cout << "Tax: $" << tax << endl;


cout << "Amount Due: $" << amountDue << endl;
}

Question 3
Code
#include <iostream>
#include <string>

using namespace std;

struct menuItemType
{
string itemName;
double price;
};

int main()
{
menuItemType menu[] = {
{"Bacon and Egg", 3.52},
{"Muffin", 1.22},
{"Coffee", 0.75}
};
cout << "Welcome to Our Restaurant" << endl;
for (int i = 0; i < 3; i++)
{
cout << i + 1 << ". " << menu[i].itemName << " $" << menu[i].price << endl;
}

double total = 0;
int choice, quantity;
while (true)
{
cout << "Enter your choice (1-3)"<<endl<<"Pree 0 for bill: ";
cin >> choice;
if (choice == 0)
break;
cout << "Enter the quantity: ";
cin >> quantity;
total += menu[choice - 1].price * quantity;
}

double tax = total * 0.05;


double amountDue = total + tax;

cout << "\nCheck" << endl;


cout << "------" << endl;
cout << "Bacon and Egg: $" << menu[0].price * 1 << endl;
cout << "Muffin: $" << menu[1].price * 2 << endl;
cout << "Coffee: $" << menu[2].price * 1 << endl;
cout << "Tax: $" << tax << endl;
cout << "Amount Due: $" << amountDue << endl;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy