Anda di halaman 1dari 5

CSE110 Assignment 1

Task 1

Draw the flowchart of a program that prints the first ten positive whole numbers. [Do NOT use loops]

Task 2

Draw the flowchart of a program that prints the first ten even positive whole numbers. (Do NOT use loop or
modulus operator for this problem).

Task 3

Draw the flowchart of a program that reads one number from the user, and prints it back to show which
number was entered by the user.

Task 4

Draw the flowchart of a program that reads two numbers from the user, and prints their sum, product and
difference.

Task 5

Draw the flowchart of a program that reads the radius of a circle and prints its circumference and area.

Task 6

Draw the flowchart of a program that reads two numbers from the user and prints “first” if the first number
is greater than the second number.

Task 7

Draw the flowchart of a program that reads two numbers from the user. Your program should then print
“first is greater” if the first number is greater, and “first is not greater” otherwise.

Task 8

Draw the flowchart of a program that reads two numbers from the user. Your program should then print
“first is greater” if the first number is greater, “second is greater” if the second number is greater, and “the
numbers are equal” otherwise.

Task 9

Draw the flowchart of a program that reads two numbers, subtracts the smaller number from the larger
one, and prints the result.

Task 10

Draw the flowchart of a program that reads a number, and prints “The number is even” or “The number is
odd”, depending on whether the number is even or odd. (Hint: use the modulus operator)
Task 11

Draw the flowchart of a program that reads five numbers from the user, and prints their average. [Do NOT
use loops]

Task 12

Draw the flowchart of a program that finds the sum of the first 100 positive numbers. Verify your answer by
calculating this sum manually. [Do NOT use loops, use the mathematical formula]

Task 13

Draw the flowchart of a program that reads five numbers as input from the user, and prints whether the
numbers are odd or even. [Do NOT use loops]

Task 14:
Draw the flowchart of a program that reads an integer, and if the number is even and greater than 10,
prints “An even number greater than 10”. If the number is even but lesser than 10, print “An even
number not greater than 10”. If the number is greater than 10 but odd, print “An odd number greater
than 10”. If the number is odd and also less than 10, print “An odd number less than 10”.

Task 15:
Draw the flowchart of a program that reads an integer, and prints the integer if it is a multiple of either
2 or 5.
For example, 2, 4, 5, 6, 8, 10, 12, 14, 15, 16, 18, 20, 22 …

Task 16:
Draw the flowchart of a program that reads an integer, and prints the integer if it is a multiple of either
2 or 5 but not both.
For example, 2, 4, 5, 6, 8, 12, 14, 15, 16, 18, 22 …

Task 17:
Draw the flowchart of a program that reads an integer, and prints the integer if it is a multiple of 2 and
5.
For example, 10, 20, 30, 40, 50 …

Task 18:
Draw the flowchart of a program that reads an integer, and prints the integer if it is a multiple of
NEITHER 2 NOR 5.
For example, 1, 3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39 …

Task 19:
Draw the flowchart of a program that reads an integer, and prints the integer if it is NOT a multiple of 2
OR NOT a multiple of 5.

Task 20:
Draw the flowchart of a program that reads a student’s mark for a single subject, and prints out “Pass”
if the student got more than 50, and “You shall not pass” otherwise.
Task 21:
Draw the flowchart of a program that reads a student’s mark for a single subject, and prints out the
corresponding grade for that mark. The mark ranges and corresponding grades are shown in the table
below.

Marks Grade

90 and above A

80-89 B

70-79 C

60-69 D

50-59 E

Below 50 F

22. Draw the flowchart that takes as input your final marks and shows as output the letter grade.
90 - 100 = A (4.0) Excellent
85 - <90 = A- (3.7)
80 - <85 = B+ (3.3)
75 - <80 = B (3.0) Good
70 - <75 = B- (2.7)
65 - <70 = C+ (2.3)
60 - <65 = C (2.0) Fair
57 - <60 = C- (1.7)
55 - <57 = D+ (1.3)
52 - <55 = D (1.0) Poor
50 - <52 = D- (0.7)
<50 = F (0.0) Failure

23. Write a flowchart for finding area of a rectangle given height and width.

24. Write a flowchart for a program that performs four functions of a calculator. The program should
request the user to enter a floating-point number, an operator and another floating-point number. It should
then carry out the specified arithmetical operation: adding, subtracting, multiplying, or dividing the two
floating-point numbers. Finally, it should display the result.

25. Write a flowchart that calculates the tax as follows:


a) No tax if you get paid less than 10,000
b) 5% tax if you get paid between 10K and 20K
c) 10% tax if you get paid more than 20K
d) NO TAX IF YOU ARE LESS THAN 18 YEARS OLD.
e) NO TAX IF YOU ARE THE PRESIDENT OF THE COMPANY
26. Write a flowchart for a program to compute and display a person’s weekly salary as determined by the
following conditions:
If the hours worked are less than or equal to 40, the person receives Tk200.00 per hour, else the
person receives Tk8000.00 plus Tk300.00 for each hour worked over 40 hours.
The program should request the hours worked as input and should display the salary as output.

27. Write a flowchart that finds the number of hours, minutes, and seconds in a given number of seconds.
For example, how many hours, minutes, and seconds are there in 10,000 seconds?

28. Suppose the following expressions are used to calculate the values of L for different values of S:

L = 3000  125S 2 if S  100


12000
if S  100
4   S 2 14900
L=

Write a flowchart of a program that reads a value of S and then calculates the value of L.

29. Write a flowchart that reads the values for the three sides x, y, and z of a triangle, and then calculates
its area. The area is calculated as follows: area  s ( s  x )( s  y )( s  z )
x yz
where s is
2

30. A leading newspaper pays all their freelance writers at a rate of Tk. 500 per published article. Draw the
flowchart for a program that will read the number of published articles for one writer, and print the total
monthly fees for that writer.

31. Given number of courses, credits in each course and per credit cost, find how much a student have to
pay for a particular semester.

32. Suppose the following expressions are used to calculate the values of P for different values of Q:

P = 6000  15Q 2 if Q  50
1000
if Q  50
3   Q 2 1900
P=

Write a flowchart that reads a value of Q and then calculates the value of P.

33. Draw the flowchart for the following:


1) Ask the user to enter the name of his favorite car.

2) Ask the user to enter a Number

3) Display the name of the user’s favorite car 4 times.

Example: If the user enters “Toyota” and 20, your program should print the name Toyota 4 times.

34. Imagine following call rates for a cell phone operator. Write a flowchart that calculates call charge given
the type of number, start and end time (hour and minute only).
F&F Other Numbers
Hour
1st 5 minute Rest 1st 5 minute Rest
Peak 4tk/min 2tk/min 7tk/min 6tk/min
Off Peak 3tk/min 1tk/min 8tk/min 5tk/min

35) Take hour from the user as input and tell it is time for which meal.
User will input the number in 24-hour format say 14 to mean 2pm, 3 to
mean 3am, 18 to mean 6pm etc.
Valid inputs are 0 to 23. Inputs less than 0 or more than 23 are
invalid in 24-hour clock.
Input will be whole numbers. For example, 3.5 will NOT be given as input.

Inputs: Message to be printed


4 to 6: Breakfast
12 to 13: Lunch
16 to 17: Snacks
19 to 20: Dinner
For all other valid inputs, say "Patience is a virtue"
For all other invalid inputs, say "Wrong time"

For example,
If the user enters 4, your program should print the message "Breakfast".
If the user enters 5, your program should print the message "Breakfast".
If the user enters 6, your program should print the message "Breakfast".
If the user enters 0, your program should print the message "Patience
is a virtue".
If the user enters 1, your program should print the message "Patience
is a virtue".
If the user enters 18, your program should print the message "Patience
is a virtue".
If the user enters 23, your program should print the message "Patience
is a virtue".
If the user enters 24, your program should print the message "Wrong Time".
If the user enters -1, your program should print the message "Wrong Time".
If the user enters 27, your program should print the message "Wrong time".

36) Assume all first semester students have 4 courses: CSE110, ENG091, MAT110, PHY111.
Credits for these courses are 3, 0, 3, and 3 respectively.
Take the grades of four courses from the user (out of 4.0 scale) and then print the GPA

Formula:
GPA
= summation of (multiplication of grade and credit of each course) divided by sum of credits
= (grade1xcredit1 + grade2xcredit2 + grade3xcredit3 ....) / (credit1 + credit 2+credit 3 ....)