0% found this document useful (0 votes)
18 views3 pages

Assignment

This document outlines 7 programming assignments for an Introduction to Programming course. The assignments include writing programs to: 1) Calculate the sum of numbers between two integers. 2) Calculate the factorial of a number. 3) Calculate the sum and factorial of numbers from 1 to a given integer. 4) Modify the previous program to change the output table layout. 5) Calculate an alternating sum expression. 6) Generate a loan repayment schedule with monthly interest. 7) Calculate annual depreciation of a car over 5 years.

Uploaded by

Yehia Elmasry
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)
18 views3 pages

Assignment

This document outlines 7 programming assignments for an Introduction to Programming course. The assignments include writing programs to: 1) Calculate the sum of numbers between two integers. 2) Calculate the factorial of a number. 3) Calculate the sum and factorial of numbers from 1 to a given integer. 4) Modify the previous program to change the output table layout. 5) Calculate an alternating sum expression. 6) Generate a loan repayment schedule with monthly interest. 7) Calculate annual depreciation of a car over 5 years.

Uploaded by

Yehia Elmasry
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/ 3

COURSE: INTRODUCTION TO PROGRAMMING (BIS227E)

LECTURERS: DR. ALI ALLAM / DR. MOHAMED SOBHY

ASSIGNMENT (9)
(1) Write a program that calculates the sum of all the numbers between M and
N, where M and N are two integers entered by the user.

(2) Write a program that calculates the factorial of a number (N), using the
following formula: [ n*(n-1)*(n-2)* … *2*1], where N is an input entered
by the user. (e.g. 5! = 5*4*3*2*1 = 120)

(3) Write a program that calculates both the sum and the factorial of all the
numbers between 1 and (m), where the value of (m) is entered by the user.

(4) Modify the previous program to change the layout of the table, as shown:

Page 1 of 3
COURSE: INTRODUCTION TO PROGRAMMING (BIS227E)
LECTURERS: DR. ALI ALLAM / DR. MOHAMED SOBHY

(5) Write a program that calculates and prints the result of the following
expression:
1 - 2 + 3 - 4 + 5 - 6 + … (m)
where (m) is an input entered by the user.

(6) A client receives a bank loan to buy a car. The banker enters the loan
amount and the interest rate, then the program prints a detailed statement of
the total amount required to be paid along a whole year (i.e. up to 12
months), as shown below. The following formula is used by the bank to
calculate the total amount according to the number of months:
Amount = Loan  (1 + Interest) month
Note: Use the PHP function pow(base,exp). i.e. pow(5,3)  53

Page 2 of 3
COURSE: INTRODUCTION TO PROGRAMMING (BIS227E)
LECTURERS: DR. ALI ALLAM / DR. MOHAMED SOBHY

(7) Given that a car depreciates over 5 years. The customer is asked to enter its
original price (e.g. $17000), as well as its residual value (e.g. $2000).
Write a program to calculate and print the following:
- The car value at the beginning of each year.
- The annual depreciation expense.
- The accumulated depreciation.
- The car value at the end of each year.
Given that:
𝑃𝑟𝑖𝑐𝑒 𝑜𝑓 𝑓𝑖𝑥𝑒𝑑 𝑎𝑠𝑠𝑒𝑡 − 𝑅𝑒𝑠𝑖𝑑𝑢𝑎𝑙 𝑣𝑎𝑙𝑢𝑒
Annual depreciation =
𝑙𝑖𝑓𝑒𝑡𝑖𝑚𝑒 𝑜𝑓 𝑎𝑠𝑠𝑒𝑡 (𝑦𝑒𝑎𝑟𝑠)
Car value at any given time = Original price – Accumulated depreciation
The output should look like the following example:

Page 3 of 3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy