Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
24 views

A1-Programming Fundamentals

Uploaded by

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

A1-Programming Fundamentals

Uploaded by

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

Programming Fundamentals

Week 03 – Programming Problems-Assignment


Name: Farhan Shakeel
Reg no.: 2024-CS-461
Section: B

Submission Deadline: 1st October-2024

Skills to be Tested:
● Writing C++ program that converts user input into the required output after doing some processing on
it. (CLO1)

Let's do some coding.

Task 01(OP): (Polygon Geometry Contest)

In a prestigious mathematics competition called the "Polygon Geometry Contest," brilliant young
mathematicians from all over the world gather to showcase their skills in geometry. The contest features a
variety of problems related to polygons, and participants need to write code to solve these problems.

The Challenge:

The problem statement for this particular challenge is as follows:

"Given an n-sided regular polygon, calculate and print the total sum of internal angles (in degrees). Use the
formula (n - 2) x 180, which gives the sum of all the measures of the angles of an n-sided polygon."

Task 02(OP): (Video Processing Application)


You are designing a program for a video processing application. The program needs to calculate the total
number of frames that will be shown in a given the number of minutes for a certain frame per second (FPS).
Take the number of minutes and frames per second as input from the user and calculate the total number of
frames.

Skill: Compiling and Executing programs while taking input from the user
Programming Fundamentals
Week 03 – Programming Problems-Assignment

Task 03(CP): (Cars Velocity Calculation)


A toy car accelerates from initial velocity to final velocity in some time. You have to write the C++ program
for calculating the Final Velocity. Take initial velocity, acceleration, and time as input from the user and
calculate the final velocity of the car, and display it on the screen.
The formula to Calculate the Acceleration is
Acceleration = (Final velocity - Initial velocity) / Time
Remember: You have to calculate the final velocity

Task 04(CP): (Weight Loss Calculation)


A clinic has hired you to develop a software tool that helps individuals calculate the time it will take to achieve
their weight loss goals by following specific recommendations. The clinic wants to provide a user-friendly
solution for their clients who are looking to lose weight and improve their health.

The doctor at the clinic has provided the following weight loss recommendations:

● Consume a daily calorie intake of 4000 calories.


Skill: Compiling and Executing programs while taking input from the user
Programming Fundamentals
Week 03 – Programming Problems-Assignment
● Engage in one hour of walking every day.

The doctor informs clients that by strictly adhering to these suggestions, they can expect to lose 1 kilogram of
weight after 15 days. The clinic wants the software to allow users to input their name and calculate the number
of days required to lose a specified amount of weight based on these recommendations.

Task 05(CP): (Summer Project)


During each summer, Ahmad and Fatima grow vegetables in their backyard and buy seeds and fertilizer from
a local nursery. The nursery carries different types of vegetable fertilizers in various bag sizes. When buying
a particular fertilizer, they want to know the price of the fertilizer per pound and the cost of fertilizing per
square foot. Write a c++ program that inputs
1. the size of the fertilizer bag in pounds.
2. the cost of the bag.
3. and the area in square feet that can be covered by the bag.
The Algorithm should then output
1. the cost of the fertilizer per pound.
2. the cost of fertilizing the area per square foot.

Skill: Compiling and Executing programs while taking input from the user
Programming Fundamentals
Week 03 – Programming Problems-Assignment
Task 06(CP): (Movie Theater)
A movie in a local theater is in great demand. To help a local charity, the theater owner has decided to donate
to the charity a portion of the total amount generated from the movie. Write a c++ program that prompts the
user to input the
1. Movie name
i. Adult ticket price
2. Child ticket price
3. The number of adult tickets sold.
4. The number of child tickets sold.
5. Percentage of the amount to be donated to the charity.
First of all, you have to Calculate the total amount generated by the total sold tickets. Then after donating to
the charity from the total amount, show the remaining amount achieved from the movie on the Screen.

Task 07(CP): (Harvest Vegetables)


A gardener is selling his harvest on the vegetables market. He is selling vegetables for N coins per kilogram
and fruits for M coins per kilogram. Write a program that calculates the earnings of the harvest in Rupees
(Rps). Assume the Rps / coin rate is fixed: 1 Rp == 1.94 coins.

Input Data and Output Data:


Four numbers are read from the console, one per line:

● First line: vegetable price per kilogram – a floating-point number.


● Second line: fruit price per kilogram – a floating-point number.
● Third line: total kilograms of vegetables – an integer.
● Fourth line: total kilograms of fruits – an integer.

The output should be the earnings of all fruits and vegetables in Rps on the console.

Skill: Compiling and Executing programs while taking input from the user
Programming Fundamentals
Week 03 – Programming Problems-Assignment

Task 08(CP): (4-digit Sum)


Imagine you have a 4-digit number that you want to explore further. You're curious about the individual digits
that make up this number and their sum. You know that there's a mathematical operator called the modulus
operator, often represented by the symbol '%', which returns the remainder when one number is divided by
another.

Here's a quick example of how the modulus operator works:

● When you take the modulus of 4 with 3, it returns 1 because 4 divided by 3 leaves a remainder of 1.
● If you try 7 % 4, it returns 3 because 7 divided by 4 leaves a remainder of 3.
● If you try 7 % 10, it returns 7 because 7 divided by 10 leaves a remainder of 7.

With this knowledge in mind, create a C++ program to calculate the sum of the individual digits of a 4-digit
number. This program will allow you to input any 4-digit number, and it will use the modulus operator to
extract each digit and find their sum.

Skill: Compiling and Executing programs while taking input from the user
Programming Fundamentals
Week 03 – Programming Problems-Assignment
Task 09(CP): (Complex Calculation)
Imagine a program that takes 15 numbers as input, with a specific plan in mind for mathematical operations.
The program's goal is to perform various calculations on these numbers in a structured manner.

Here's how the program works:

1. The program prompts the user to enter 15 numbers, one at a time.


2. It then proceeds to execute three distinct mathematical operations:
○ It adds together the first 5 numbers.
○ It multiplies the next 5 numbers.
○ It subtracts the last 5 numbers.
3. After obtaining the results of these three operations, the program continues its mathematical
exploration:
○ It adds the results of the addition and multiplication.
○ It subtracts the result of the subtraction.
4. Finally, the program displays the ultimate result on the screen.

Task 10(CP): (Residence History)

You are tasked with developing a program to analyze a person's residence history and calculate the average
duration they've spent living in a single house. This calculation is based on two critical factors: the person's
current age and the number of times they've moved from one house to another.

Input Data:

Skill: Compiling and Executing programs while taking input from the user
Programming Fundamentals
Week 03 – Programming Problems-Assignment
1. The person's age (age) represented as an integer.
2. The number of times they've moved house (moves) also represented as an integer.

The goal is to develop a program that can efficiently calculate the average number of years the person has
lived in a single house based on this input.

Task11(CP): (Paint Walls)

I have a bucket containing an amount of navy-blue paint and I'd like to paint as many walls as possible.
Create a program that prints the number of complete walls that I can paint, before I need to head to the shops
to buy more.

● n is the number of square meters I can paint.


● w and h are the widths and heights of a single wall in meters.

Notes

● Don't count a wall if I don't manage to finish painting all of it before I run out of paint.
● All walls will have the same dimensions.
● All numbers will be positive integers.

Skill: Compiling and Executing programs while taking input from the user
Programming Fundamentals
Week 03 – Programming Problems-Assignment

Task12(CP): (Food for Thought)


Write a program that takes 5 integers from the user and displays their sum on screen. But you can only use
two variables.

Good Luck and Best Wishes !!


Happy Coding ahead :)

Skill: Compiling and Executing programs while taking input from the user

You might also like