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

Assignment 3

assignment for practice for c++ programs

Uploaded by

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

Assignment 3

assignment for practice for c++ programs

Uploaded by

ameafzal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Topics: Week 9- 10 Total Marks: 50 Obtained Marks:

Registration No. : L1_______BSCS____________ Date:

Section: A Name:
Questions Attempted (Y/N)
Question 1:

Taxonomy
CLO # CLO Statement PLO
Level

Solve basic problems using fundamental concepts of programming C3


2 2
language (C++). (Apply)

Submission:
Soft Copy Deadline: 09-01-2025 till 11:59 PM via Portal
Hard Copy Deadline: 09-01-2025
Late Submission Policy:
 10% Deduction /24 Hours.
Submission Marks:
 5 marks are for submission.
Instructions: (5 marks will be deducted for not following the instructions)
 This is an individual assignment. Viva can be conducted OR a Quiz will be taken on the
basis of assignment in the next week.
 Attempt all questions in sequence. Attach this title page as a front page of assignment.
 Assignment should be handwritten/printed on A4 sized page. (No pages from register
please.)
 Submit Hard copy in class and scanned copy of solved assignment on the portal (Both
copies should be submitted before deadline)

UNIVERSITY OF CENTRAL PUNJAB

FALL 2024
Course Title: Introduction to Computing
Course Code: CP103
Assignment No. 3
Introduction to Computing (Fall 2024) – Assignment 3

A scenario is given to you. Apply the concepts learned to solve the real-world problems given below
using selection statements, loops, and one-dimensional arrays in C++.
Question: 1 [20 Marks]

Write a program which ask the user to input a number as input greater than or equal to four digits.
Then find the sum of entered number until the result is in single digit as follows. Sample output is
given below:

Enter a number (at least 4 digits): 4568


Intermediate sum: 23
Intermediate sum: 5
Final single-digit sum: 5

Question: 2 [30 Marks]

Scenario:
A small airline has just purchased a computer for its new automated reservations system. The
president has asked you to program the new system. You’ll write a program to assign seats on each
flight of the airline’s only plane (capacity: 10 seats). Your program should display the following
menu of alternatives:
 Please type 1 for "first class"
 Please type 2 for "economy"
 If the person types 1, then your program should assign a seat in the first class section (seats
1–5).
 If the person types 2, then your program should assign a seat in the economy section (seats
6–10).
 Your program should then print a boarding pass indicating the person's seat number and
whether it’s in the first class or economy section of the plane.
 Use a single-subscripted array to represent the seating chart of the plane.
 Initialize all the elements of the array to 0 to indicate that all seats are empty.
 As each seat is assigned, set the corresponding element of the array to 1 to indicate that the
seat is no longer available.
 Your program should, of course, never assign a seat that has already been assigned.
 When the first class section is full, your program should ask the person if it’s acceptable to be
placed in the economy section (and vice versa).
 If yes, then make the appropriate seat assignment. If no, then print the message "Next flight
leaves in 3 hours."
 Sample Output is given below:

Airline Reservation System


Please type 1 for "First Class"
Please type 2 for "Economy"
Enter your choice: 1
Boarding Pass: Seat 1 (First Class)

Airline Reservation System


Please type 1 for "First Class"
P.T.O University of Central Punjab
Introduction to Computing (Fall 2024) – Assignment 3
Please type 2 for "Economy"
Enter your choice: 1
Boarding Pass: Seat 2 (First Class)

Airline Reservation System


Please type 1 for "First Class"
Please type 2 for "Economy"
Enter your choice: 1
Boarding Pass: Seat 3 (First Class)

Airline Reservation System


Please type 1 for "First Class"

Please type 2 for "Economy"


Enter your choice: 2
Boarding Pass: Seat 6 (Economy)

Airline Reservation System


Please type 1 for "First Class"
Please type 2 for "Economy"
Enter your choice: 2
Boarding Pass: Seat 7 (Economy)

Airline Reservation System


Please type 1 for "First Class"
Please type 2 for "Economy"
Enter your choice: 1
Boarding Pass: Seat 4 (First Class)

Airline Reservation System


Please type 1 for "First Class"
Please type 2 for "Economy"
Enter your choice: 1
Boarding Pass: Seat 5 (First Class)

Airline Reservation System


Please type 1 for "First Class"
Please type 2 for "Economy"
Enter your choice: 1
First Class is full. Would you like to be placed in Economy? (1 =
Yes, 0 = No): 1

Airline Reservation System


Please type 1 for "First Class"
Please type 2 for "Economy"
Enter your choice: 2
Boarding Pass: Seat 8 (Economy)

Airline Reservation System


Please type 1 for "First Class"
Please type 2 for "Economy"
Enter your choice: 1
First Class is full. Would you like to be placed in Economy? (1 =
Yes, 0 = No): 0
P.T.O University of Central Punjab
Introduction to Computing (Fall 2024) – Assignment 3
Next flight leaves in 3 hours.

Airline Reservation System


Please type 1 for "First Class"
Please type 2 for "Economy"
Enter your choice: 2
Boarding Pass: Seat 9 (Economy)

Airline Reservation System


Please type 1 for "First Class"
Please type 2 for "Economy"
Enter your choice: 2
Boarding Pass: Seat 10 (Economy)
The plane is fully booked. Next flight leaves in 3 hours.

Instructions:

 You have to make a program for the problem given above.


 You have to analyze and think critically which programming concepts can be used
throughout the program (use of compound expression, use of if-else/ nested if, switch/ nested
switch, logical OR relational operators, arrays), where applicable.
 Write a program for problem and paste the code as answer to the problem.
 Run the program and paste screenshot for one output.

Note: Plagiarism will result in 0 marks.

P.T.O University of Central Punjab


Introduction to Computing (Fall 2024) – Assignment 3

Rubrics for Assignment Evaluation:

Here are the criteria mentioned below for your assessment evaluation. Give it a read before attempt
the assignment. You should read it properly for securing good marks.

Rubrics Detail/ Rubrics Above Sufficient Developing Needs Marks Obtained


Criteria Averag Improvement Distribution Marks
e
Presentation of Above average = 3
marks
Assignment (The use of Sufficient = 2 marks
front page, page borders, Developing = 1.5
page no’s, table of contents, marks
indentation, use of diagrams/ Needs improvement
= 1 mark
tables where required).
Assignment structuring Above average= 2
marks
(proper use of headings & Sufficient = 1.5
sub-headings, use of bullets marks
& keywords where required Developing = 1
and proper division marks
Needs improvement
according to the questions = 0.5 mark
asked in assignment).
Program Logic (How well Above average= 5
marks
you design the solution to Sufficient = 3.5
program logically. Right use marks
of programming concepts). Developing = 2.5
marks
Needs improvement
= 2 marks
Program Ethics (Use of Above average= 5
marks
proper naming conventions Sufficient = 3.5
in program, indentation & marks
no. of lines) Developing = 2.5
marks
Needs improvement
= 2 marks
Correct Output (Correction Above average= 5
marks
of program output, does the Sufficient = 3.5
program implementing the marks
things for which it was Developing = 2.5
designed?) marks
Needs improvement
= 2 marks

P.T.O University of Central Punjab

You might also like