0% found this document useful (0 votes)
26 views2 pages

PF Assignment 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

PF Assignment 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Programming Fundamentals Assignment 1

Instructions:
 Assignment must be submitted handwritten.
 Assignment must have a cover page including students registration number, name,
discipline (BSSE, BSAI, BSCS) and section
 Copied assignment will be marked 0
 Assignment must be submitted in second lecture of week 7
 After dead line assignment will not be accepted
 You are also required to solution file of your assignment in lab.

Note : All the question carry 25 marks.


Program 1: In a movie theater, the ticket prices vary based on the age of the customer. For adults,
the ticket costs Rs1000, for kids, it's half that price, and for senior citizens, there's a 20% discount.
A customer arrives at the theater with five family members. You need to create a C++ program
that calculates the total amount the customer has to pay based on the ages of all family members.
Here are the pricing rules:
 If the age is less than 15, it's considered a child's ticket price.
 If the age is between 15 and 59, it's considered an adult ticket price.
 If the age is 60 or older, it's considered a senior citizen price."
Program 2: A student is currently enrolled in the third semester of their degree program. The
task is to input the Cumulative Grade Point Average (CGPA) for each semester and provide one
of the following messages:
 'CGPA is same' (if the CGPA remains constant across all semesters).
 'CGPA is improving' (if the CGPA increases with each subsequent semester).
 'CGPA is decreasing' (if the CGPA decreases with each subsequent semester).
 'CGPA is not predictable' (if the CGPA shows both increasing and decreasing trends
across semesters).
Program 3: Write a C++ program that takes the populations of three countries: Pakistan, China,
and Afghanistan as input. Then, use logical operators to determine and display which country has
the highest population. Display country name along with population.
Program 4: You need to create a C++ guessing game where two random numbers are generated.
Your program will prompt the user to provide the sum of these numbers. If the user enters the
correct answer, it should display "Congratulations, you scored 100%." If the answer is incorrect,
it should display "Wrong, please enter your answer again." If the user eventually enters the correct
answer, it should display "Congratulations, you scored 66%." If the answer is incorrect once more,
it should ask the user to try again. If the user eventually enters the correct answer at this point, it
should display "You scored 33%." If none of the answers are correct, it should display "Better luck
next time."
Sample Execution 1 Sample Execution 2 Sample Execution 3 Sample Execution 4
What is the sum of 7 What is the sum of 7 What is the sum of 7 What is the sum of 7
and 2? 9 and 2? 10 and 2? 10 and 2? 10
Congratulations, you Wrong, please enter Wrong, please enter Wrong, please enter
scored 100% your answer again: 9 your answer again: 5 your answer again: 5
Congratulations, you Wrong, please enter Wrong, please enter
scored 66% your answer again: 9 your answer again: 15
You scored 33% Wrong, please enter
your answer again: 2
Better luck next time

Note: In above sample execution 7 and 2 are two random numbers that can be any random
numbers code for random number generation is given below
#include <iostream>
#include <cstdlib> // Include the necessary header for rand() and
srand()
#include <ctime> // Include the necessary header for time()

void main() {
// Seed the random number generator with the current time
srand(static_cast<unsigned>(time(0)));

// Generate a random number between 1 - 100


int random_number = rand() % 101;

// Output the random number


std::cout << "Random number between 1 and 101: " <<
random_number << std::endl;

system("pause");
}

You might also like