0% found this document useful (0 votes)
758 views

CSC126 - Individual Assignment - Report

This document is for an individual assignment in CSC126. It includes two questions that require C++ programs to be written. Question 1 requires a program to convert meters to feet. Question 2 requires a more complex program to calculate the total price for movie tickets, food, and drinks based on user input. Both questions provide sample inputs and outputs. The assignment will be marked out of 50 and assessed based on criteria like coding standard, efficiency, runtime, and meeting specifications.

Uploaded by

Nurul Aqilah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
758 views

CSC126 - Individual Assignment - Report

This document is for an individual assignment in CSC126. It includes two questions that require C++ programs to be written. Question 1 requires a program to convert meters to feet. Question 2 requires a more complex program to calculate the total price for movie tickets, food, and drinks based on user input. Both questions provide sample inputs and outputs. The assignment will be marked out of 50 and assessed based on criteria like coding standard, efficiency, runtime, and meeting specifications.

Uploaded by

Nurul Aqilah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

CSC126

INDIVIDUAL ASSIGNMENT

SEQUENCE CONTROL STRUCTURE


AND
SELECTION CONTROL STRUCTURE

SEMESTER:
OCTOBER 2023 – FEBRUARY 2024

Name : Nurul Aqilah Binti Mohamad Yazid


Student ID : 2022822636
Group : AS1143A2
Lecturer Name : Dr. Nur Ida Aniza Binti Rusli

Attributes Score Weightage Marks


Coding Standard 2
Efficiency 2
Runtime 2
Delivery 1
Specifications 3
Total Marks /50

CSC INDIVIDUAL ASSIGNMENT 1


Question 1

C++ program

#include <iostream>

Using namespace std;

Int main ()

Float meter, feet;

Cout << “Enter distance in meter: “;

Cin >> meter;

Feet = meter*3.28084;

Cout << “The distance in feet is: “ << feet << endl;

CSC INDIVIDUAL ASSIGNMENT 2


Sample Input and Output

First trial
Input Distance in meter: 50
Output

Second trial
Input Distance in meter: 10.5
Output

Third trial
Input Distance in meter: 128.9
Output

CSC INDIVIDUAL ASSIGNMENT 3


Question 2
C++ program
#include <iostream>
#include <iomanip>
using namespace std;

int main ()
{
int age, numTicket, numFood, numDrink;
float ticketPrice, totalTicketPrice, totalDiscount, totalPriceAfterDiscount,
foodPrice, totalFoodPrice, drinkPrice, totalDrinkPrice, finalPrice;
char movie, food, drink;

cout << "Enter your age: ";


cin >> age;
cout << "Enter your choice of movie (M-Matinee, E-Evening): ";
cin >> movie;
cout << "Enter the quantity of tickets: ";
cin >> numTicket;
cout << "Select your food (P-Popcorn, H-Hotdog): ";
cin >> food;
cout << "Enter the quantity of foods: ";
cin >> numFood;
cout << "Select your drink (S-Soda, M-Mineral Water): ";
cin >> drink;
cout << "Enter the quantity of drinks: ";
cin >> numDrink;

if ((age<=12) && (movie=='M'))


ticketPrice=10.00;

CSC INDIVIDUAL ASSIGNMENT 4


else if ((age<60) && (movie=='M'))
ticketPrice=20.00;
else if ((age<=12) && (movie=='E'))
ticketPrice=12.00;
else if ((age<60) && (movie=='E'))
ticketPrice=25.00;
else if ((age>=60) && ((movie=='M') || (movie=='E')))
ticketPrice=12.00;
else
ticketPrice=0.00;

totalTicketPrice=numTicket*ticketPrice;

if (numTicket>5)
totalDiscount=totalTicketPrice*0.15;
else
totalDiscount=0.00;

if (numTicket>5)
totalPriceAfterDiscount=totalTicketPrice-totalDiscount;
else
totalPriceAfterDiscount=totalTicketPrice;

if (food=='P')
foodPrice=9.00;
else if (food=='H')
foodPrice=6.00;
else
foodPrice=0.00;

CSC INDIVIDUAL ASSIGNMENT 5


totalFoodPrice=foodPrice*numFood;

if (drink=='S')
drinkPrice=6.00;
else if (drink=='M')
drinkPrice=2.00;
else
drinkPrice=0.00;

totalDrinkPrice=drinkPrice*numDrink;

finalPrice=totalPriceAfterDiscount+totalFoodPrice+totalDrinkPrice;

cout << "============================================" << endl;


cout << " Silver Screen Cinema " << endl;
cout << " Cinema Ticket Booking System " << endl;
cout << " Receipt " << endl;
cout << "============================================" << endl;
cout << "Age: " << age << endl;
cout << "Movie Type: " << movie << endl;
cout << "Ticket Price: RM " << fixed << setprecision(2) << ticketPrice <<endl;
cout << "Quantity of Tickets: " << numTicket << endl;
cout << "Total Ticket Price: RM " << fixed << setprecision(2) << totalTicketPrice
<< endl;
cout << "Discount Applied: RM " << fixed << setprecision(2) << totalDiscount <<
endl;
cout << "Total Price After Discount: RM " << fixed << setprecision(2) <<
totalPriceAfterDiscount << endl;
cout << "Food: " << food << endl;
cout << "Food Price: RM " << fixed << setprecision(2) << foodPrice << endl;
cout << "Food Quantity: " << numFood << endl;

CSC INDIVIDUAL ASSIGNMENT 6


cout << "Total Food Price: RM " << fixed << setprecision(2) << totalFoodPrice <<
endl;
cout << "Drink: " << drink << endl;
cout << "Drink Price: RM " << fixed << setprecision(2) << drinkPrice << endl;
cout << "Drink Quantity: " << numDrink << endl;
cout << "Total Drink Price: RM " << fixed << setprecision(2) << totalDrinkPrice
<< endl;
cout << "-----------------------------------------" << endl;
cout << "Final Price: RM " << fixed << setprecision(2) << finalPrice << endl;
cout << "-----------------------------------------" << endl;

CSC INDIVIDUAL ASSIGNMENT 7


Sample Input and Output

First trial

Input
Output

CSC INDIVIDUAL ASSIGNMENT 8


Sample Input and Output

Second trial

Input
Output

CSC INDIVIDUAL ASSIGNMENT 9


Sample Input and Output

Third trial

Input
Output

CSC INDIVIDUAL ASSIGNMENT 10

You might also like