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

Week 2 Assignment1 OOP

The document is an assignment for the CS-122 Object Oriented Programming course at the National University of Technology, detailing tasks for students to complete. It includes programming tasks such as determining odd/even numbers, calculating digit sums, checking for prime numbers, reversing strings, counting vowels and consonants, calculating factorials, generating Fibonacci series, and a scenario involving interest calculations for fixed deposits. Students are instructed to submit handwritten assignments with specific output requirements and are warned against late submissions and plagiarism.

Uploaded by

zaheenaanwar123
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)
30 views2 pages

Week 2 Assignment1 OOP

The document is an assignment for the CS-122 Object Oriented Programming course at the National University of Technology, detailing tasks for students to complete. It includes programming tasks such as determining odd/even numbers, calculating digit sums, checking for prime numbers, reversing strings, counting vowels and consonants, calculating factorials, generating Fibonacci series, and a scenario involving interest calculations for fixed deposits. Students are instructed to submit handwritten assignments with specific output requirements and are warned against late submissions and plagiarism.

Uploaded by

zaheenaanwar123
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

National University of Technology (Nutech)

Department of Computer Science


Assignment # 1
COURSE: CS-122 Object oriented programming

Batch: CS-SECTION (A+B)​ ​ Semester: 2​ Instructor: Ms. Tayyaba Kalsoom


Total Marks: 10​ ​ Assigned Date: 27-2-2025 Due Date:6-3-25

Name: __________________________________ Roll #_________________________________

Question No. 01: (CL01)​ ​ ​ ​ ​ ​ ​ ​ (10 Marks)

Instruction to be followed while submitting your assignment


1.​ Hand written assignment.
2.​ Output should be attached in printed form(separately).
3.​ Code to be run (Dry Run) by taking at least three input values against each
variable.
4.​ Late submission will be marked ZERO.
5.​ Plagiarized or copied assignments are not acceptable.

Task 1: Write a program that takes an integer as input and uses an 'if-else' statement to determine if
the number is odd or even. Output 'Odd' if the number is odd, and 'Even' if it is even."

Task 2: Write a program that takes a non-negative integer as input. Calculate and return the sum of
the digits that make up the integer. Handle the case where the input is negative by returning an
appropriate indicator."

Task 3: "Write a function that accepts an integer as input and returns a boolean value (true or false)
indicating whether the input is a prime number. Use the square root optimization to improve
efficiency."

Task 4: write a program for the following instructions

●​ "1. Get a string as input.


●​ 2. Create an empty string to store the reversed string.
●​ 3. Iterate through the input string from the last character to the first.
●​ 4. For each character, append it to the reversed string.
●​ 5. Print the reversed string."

Page 1 of 2
Task 5: "Write a function that accepts a string as input and returns two values: the count of vowels and
the count of consonants. Consider only alphabetic characters and ignore the numeric values.

Task 6: "Create a program that calculates the factorial of a positive integer using a loop. The factorial
of a number 'n' is the product of all positive integers less than or equal to 'n'. For example, 5! = 5 * 4 *
3 * 2 * 1 = 120."

Task 7: Write a program that generates the Fibonacci series up to a given number of terms.
For example, if the user enters 5, the output should be: 0, 1, 1, 2, 3

Task 8: "Mrs. Eleanor Vance, a retired school teacher, walks into your bank branch.
She's interested in opening a fixed deposit account. She tells you she's 68 years old and
wants to deposit $10,000 for one year.

At the same time, a young professional, Mr. David Crane, approaches your desk. He's
35 years old and wants to deposit $5,000 for one year in a similar fixed deposit account.

Your bank has a policy:

●​ Senior citizens (age 70 or more) receive a 20% annual interest rate.


●​ Depositors under 60 years old receive a 10% annual interest rate.

Questions:

1.​ Calculate the interest earned by Mrs. Vance and Mr. Crane.
2.​ What is the total amount (principal + interest) each depositor will have at the end of one
year?
3.​ Explain the logic (using if-else conditions) that your bank's system would use to
determine the interest rate for each customer.
4.​ If the bank decided to add a new condition: 'If the deposit amount is over $15,000, an
additional 0.5% interest is added regardless of age.' How would you modify your logic
and calculations to accommodate this new condition? Assume Mrs. Vance deposits
$16,000.
5.​ Write a java code snippet that implements the logic of the first three questions."

Page 2 of 2

You might also like