You are on page 1of 3

CS 101 Computing & AI

Assignment 02
Date of Announcement: 10-20-2022 Submission Deadline: 10-27-2022 Mid Night (11:59 PM)

Instructions
● You are required to submit a separate C++ file for each Question.
● Each file should be named with the Question Number e.g. question_09.cpp. You
should zip all your questions in one file.
● Make sure your code is compiling before submission, if the code does not compile for a
particular question it will be graded 0.
● Each variable in your code should be modified with the last 3 digits of your registration
number as well as the first 3 alphabets of your name.
○ E.g. Student name: Ali, Registration u2022012
○ Each variable in the code should look like this: int ali_num1_012;
○ Another example for naming the variable num2, and salary of int data type
■ int ali_num2_012, ali_salary_012;
● Late submissions will receive -25% for each day. Hence, after 4 days your assignment
will receive 0 marks.
● Cheating will not be tolerated. All identicals assignment will be graded 0.
● You have the option to leave the bonus questions, however, solving these will provide
you with the additional score.

Question 01
You are writing a voter eligibility function, ask the user for their date of birth (Year, month, and
day) and display “You are eligible to vote” if they are above 18 years on 12 October 2023,
otherwise display “you are not eligible to vote”.

Question 02
Write a program to input a number from the user, and check if the number is even or odd as
well as if the number is positive or negative.

Sample Input

Enter Number: -10

Sample Output:

Number is Negative and Even.


Question 03
Write a program that takes 10 characters from the user and counts how many characters were
vowels and how many characters were consonants. Tell the user if s/he has entered more
vowels or consonants. Also, display the count of both vowels and consonants.

Question 04
You are requested to ask the user for a username of 3 characters and a password of 3
characters only. Then ask for the username and password from the user, if the username and
password match displays the message “You have successfully logged in”, otherwise display
“Wrong username Or Password”.

Question 05
You are requested to write a program that selects the students for the scholarship. Calculate
the GPA of the first-semester student and if their GPA is above 3.8 he has qualified for a full
scholarship if it is above 3.5 and below 3.8 then a 75% scholarship is offered, if the GPA is above
3.3 and below 3.5 then a 50% scholarship will be provided by the university. Below 3.3 receive
no scholarship.

GPA of Semester = For each subject: (obtained grade x credit hours) / (Total credit hours of the

semester)

Grades and GPA relation is shown below

Letter Grade Point Value of Grade

A 4

B 3.5

C 3

D 2.5

E 2.0

F <2.0

Question 06
Input two numbers from the user and a character that represents the operation. If the user has
entered “+” after two numbers then display “Sum of 10 and 20 is 30” (here we suppose 10 was
the first number and 20 was the second). Similarly, perform subtraction (-), division (/),
multiplication (*), modulus (%), square (for square 2), and cube ( for cube 3 ). For square and
cube, you will print the square of both numbers. You will also perform the relational check on
the given numbers if both numbers are equal (for equality =), find the greater number (for
greater number >), and find the smaller number (for smaller number <).

Question 07
You are writing a program to educate young Muslims about the Quran. You ask the user for the surah
number and tell the user if the Surah was revealed to our beloved Prophet Hazrat Muhammad (SAWW,
Seal of Prophets) during his life in Makkah or Madinah.

You can visit the following link to get the details of Surahs by Makki and Madni.

https://www.prayertimenyc.com/number-makki-madani-surah-in-quran/

Sample Input
Input Surah Number: 67

Sample Output
The Surah is Makki

Question 08 (Bonus Question)


Ask the user time of the day (24 hours format, 13:15) based on the time suggest prayer to offer.
For example: if the user enters 5:15 then it is Fajar Time.
Topi Prayer timings are given below
Fajar: 4:55 Sunrise: 6:18
Zohar: 11: 55
Asar: 15:52
Maghrib: 17:31
Isha: 18:55
Question 09 (Bonus Question)
To further the education of the Quran for young Muslims you are extending the functionality of your
Software. Now you provide the option to the user if they want to find the Makki/Madni details of the
Surah or if they want to search for the Para/Juz details (1 - 30).

Sample Input:
For Surah Details Enter 1, For Para/Juz Details Enter 2: 2

Enter Para/Juz Number: 23

Sample Output:
23 Para/Juz of Quran-e-Kareem is Wa Mali.

It contains 4 Surahs, names are given below.

Surah Ya-Seen
Surah Saffat
Sura Saad
Surah Az-Zumar

You might also like