Sie sind auf Seite 1von 7

A mathematical generating a sequence of numbers from any positive integer n (n >

0) as follows:
If n is 1, stop.
If n is even, the next number is n/2.
If n is odd, the next number is 3*n + 1.
Continue with this process until reaching 1.
Here are some examples for the first few integers.
2 -> 1
3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1
4 -> 2 -> 1
5 -> 16 -> 8 -> 4 -> 2 -> 1
6 -> 3 -> etc as for 3 above.
7 -> 22 -> 11 -> 34 -> 17 -> 52 -> 26 -> 13 -> 40 -> 20 -> 10 -> 5 ->
See 5 above.
Draw a FCD using Visual Logic that reads a number and prints the mathematical sequence
for it.
=============================================================
Draw a FCD using Visual Logic that reads daily temperatures, as floats. The user key
in the number of data sets to be process. Read in a loop until all data have been
read. After the input has been read, print the maximum and minimum values. You can
assume that there is at least one input data value.
Enter number of input values: 7
Sample input values

10.0 11.3 4.5 -2.0 3.6 -3.3 0.0

The output should look something like the following. Formatting may vary.

Maximum = 11.3
Minimum = -3.3
===========================================================================
Draw a FCD using Visual Logic which reads a sequence of integers and counts how
many times the number 55 occurs. Print the count. For example, If the user input
the number of integers to be process as 8 and the integer you are to search from, with
input values 55 25 1004 4 -6 55 0 55, the output should be 3 because there were 3 55's
in the input stream. Your program should work for any input, not just this example.

========================================================================
Draw a FCD using Visual Logic that will accept an n integer from the user via the
keyboard, The dialog for this program should look as follows:
Enter number of integers to process: 3
Enter the integers: 7 20 17
Largest = 20
Smallest = 7
Median = 17
===============================================================================
Draw a FCD using Visual Logic should read in values until a negative value is read in.
It should determine the largest value that was read in and display that value once the
loop stops. A sample dialog for this program looks as follows:
Enter an integer: 5
Enter an integer: 1
Enter an integer: 15
Enter an integer: 9
Enter an integer: -1
Largest = 15
==============================================================================
Draw a FCD using Visual Logic should read in values until a negative value is read in.
It should determine the smallest value that was read in and display that value once
the loop stops. A sample dialog for this program looks as follows:
Enter an integer: 5
Enter an integer: 1
Enter an integer: 15
Enter an integer: 9
Enter an integer: -1
Smallest = 1
===============================================================================
Draw a FCD using Visual Logic that should first read in two values from the keyboard, a
starting value and an ending value. It should sum all the even numbers between
those two values including the endpoints and display the sum. If the ending point is
less than the starting point, the sum should be 0. A sample dialog for this program looks
as follows:
Enter starting and ending: 12 15
Sum of evens = 26

Draw a FCD using Visual Logic that should first read in two values from the keyboard, a
starting value and an ending value. It should sum all the odd numbers between
those two values including the endpoints and display the sum. If the ending point is
less than the starting point, the sum should be 0. A sample dialog for this program looks
as follows:
Enter starting and ending: 10 20
Sum of odds = 75
==============================================================================
Draw a FCD using Visual Logic that computes the sum of all the integers in a range
specified by the user. The program would accept two parameters that specify a lower
and upper bound. It should compute the sum of all the integers between those bounds,
inclusive, and display that sum. A sample dialog for this program looks as follows:
Enter a lower and upper bound: 2 4
Sum = 9
Enter 0 to quit, 1 to continue: 0
==============================================================================
Draw a FCD using Visual Logic that sums the values that are input that are within the
specified bounds. The algorithm should prompt the user for the lower and upper bounds
and then successively prompt the user for values until a negative value is input. The
program should also determine whether the value is within bounds. The program
should accept the value and the bounds as parameters and return a Boolean value
indicating whether the value is with the bounds inclusive of the end points. A
sample dialog for this program looks as follows:
Enter bounds: 10 20
Enter value: 15
Enter value: 5
Enter value: 10
Enter value: -1
Sum = 25
Note: Do not reverse the lower and upper bounds supplied by the user if the lower
bound if greater than the upper. If the lower bound was a 10 and the upper bound a
5, for example, the sum should be zero no matter what values are input.
=======================================================
Draw a FCD using Visual Logic that reads in integers as long as they continue to be
input in increasing order, that is each successive number must be greater than or
equal to the previous. As soon as the sequence is no longer increasing the program
should stop and output the number of values in increasing order. A sample dialog for
this program looks as follows:
Enter a number: 2
Enter a number: 5
Enter a number: 7
Enter a number: 0
Increasing count = 3
==============================================================================
Draw a FCD using Visual Logic that prompts the user for a number and computes the nth
term of the following sequence of numbers referred to as the sequence of pentagonal
numbers:

A sample dialog for this program looks as follows:


Enter a number: 5
Sum = 35
==============================================================================
Draw a FCD using Visual Logic that prompts the user for two integers, reads them in
and then allows the user two choices: to compute the minimum of those two
values or the maximum. If the user inputs an invalid choice, set the result to 0. A
sample dialog for this program looks as follows:
Enter two integers: 8 35
Enter 1 for min, 2 for max: 1
Result = 8
==================================================================
Draw a FCD using Visual Logic that reads in integers until 10 have been read in or
until a negative number has been input. As the numbers are read in they should be
summed and the sum should be displayed once all the integers have been input. The
negative integer, should be one of the inputs and 10 are not to be included in the sum.
A sample dialog for this program looks as follows:
Enter an integer: 8
Enter an integer: 2
Enter an integer: -1
Sum = 10
===============================================================================
Draw a FCD using Visual Logic that requests the user to input an integer n. It should
compute the sum of the first n integers that are multiples of 3, the sum 3 + 6 + ... +
3n, using the following formula:

A sample dialog for the program is shown below:


Enter an Integer: 3
Sum = 18
=========================================================
Draw a flowchart diagram using Visual Logic that reads the lengths of three sides of a
triangle and prints out the classification of the triangle as follows:
invalid input: all sides must have lengths that are strictly positive
not a triangle: the sum of any two sides must be greater than the length of the
third
scalene triangle: no two sides have equal length
isosceles triangle: two sides (but not the third) are equal
equilateral triangle: all three sides are equal

Provide validation all data entries and ask if the user wants to try running again the
program.
Enter the three sides of a triangle: 2.5 2.5 2.5
IT’S AN EQUILATERAL TRIANGLE.
============================================================================

Write a Python code that asks the user to enter his or her weight and the name of a
planet. The algorithm was then to output how much the user would weigh on that
planet. . The following table gives the factor by which the weight must be multiplied for
each planet. The program should output an error message if the user doesn't type a
correct planet name. The prompt and the error message should make it clear to the
user how a planet name must be entered.
Mercury 0.4155
Venus 0.8975
Earth 1.0
Moon 0.166
Mars 0.3507
Jupiter 2.5374
Saturn 1.0677
Uranus 0.8947
Neptune 1.1794
Pluto 0.0899

Write a Python Code that reads a time in numeric form and prints it in English. The
time is input as hours and minutes, separated by a space. Hours are specified in 24-
hour time (15 is 3 p.m.), but the output should be in 12-hour a.m./p.m. form. Note
that noon and midnight are special cases. Here are some examples:
Enter time: 12 00
Noon

Enter time: 0 00
Midnight

Enter time: 6 44
Six forty four AM

Enter time: 18 11
Six eleven PM
Write a Python code that computes the grade of a student using the formula:

Grade = 40% major exam + 30% ave of 2 long exams + 30% ave of 3 short quizzes
Display the average of 2 long exams, average of 3 quizzes and the grade of the
student. Display also a message whether the student passed or failed. Passing is
75%.
Computing for the student’s grade…

Enter your Midterm Exam Grade :> 100


Enter your Long Exam 1 Grade :> 100
Enter your Long Exam 2 Grade :> 100
Enter your Short Quiz 1 Grade :> 100
Enter your Short Quiz 2 Grade :> 100
Enter your Short Quiz 3 Grade :> 100

Average of 2 Long Exam :> 100.00


Average of 3 Short Quiz :> 100.00
Your Grade is :> 100.00

Congrats! You PASSED!

=========================================================================================
Write a Python code that asks the user for the hours worked for the week and the
hourly rate. The basic salary is computed as:
Salary = hours worked * hourly rate
Bonuses are given:
No. of hours >45 Bonus of 500 pesos
No. of hours >40 and <= 45 Bonus of 250 pesos
No. of hours >35 and <=40 Bonus of 150 pesos
Display the basic salary, bonus and the total salary (basic salary + bonus) for the
week.

Computing the weekly basic salary and bonus…

Hours worked for the week :> 12


Hourly Rate :> 20

Basic Salary :> 240.00


Bonus :> 0.00
Total Salary :> 240.00

=========================================================================================
Write a Python code that uses the algorithm of a XYZ company gives year-end bonus
to its employees based on their number of years of service and their salary,
using the following:
Years of Service Bonus
1 10% of salary
2 to 5 20% of salary
6 to 10 50% of salary
11 and above 75% of salary

XYZ Company year-end bonus computer…

Year of Service :> 15


Salary :> 5000

Bonus :> 3750.00


Total Salary :> 8750.00

Write a Python code that accepts five numbers from the user and displays the highest
and lowest number. Assume that there are no duplicate values.

Determine the highest and lowest among five


numbers…

Input Number :> 5


Input Number :> 97
Input Number :> 58
Input Number :> 24
Input Number :> 64

Highest is :> 97.00


Lowest is :> 5.00
===========================================================================================
Write a Python code that will ask the user if he wants to compute the perimeter of the area of
rectangle. If the perimeter is wanted, ask the measure of the three sides and compute
for the perimeter. If the area is wanted, ask for the measures of the base and height
and compute for the area. Display the computed value.
Choices:

(P) Perimeter of Triangle


(A) Area of Triangle

Your Choice: P

Perimeter of Triangle…

Enter 1st Side :> 5


Enter 2nd Side :> 9
Enter 3rd Side :> 8

Perimeter is: 22.00

=====================================================
Write a Python code that gives a discount of 100 pesos to a customer if the shirt
bought is XL and the price is greater than 500 pesos; a discount of 50 pesos if the
shirt bought is L and the price is greater than 400.

Program that will compute the discount of the purchased Shirt…

Shirt’s Size (XL, L, S, M) :> L


Shirt’s Prize :> 780

Discount is: 50.00


Total Prize : 730.00

Write a Python code to determine the equivalent grade of each student in class as
follows:
a. Read in the student's name, midterm grade, minor B and final exam ratings.
b. Determine the final grade of the student by the formula:
final grade=0.30 of midterm grade + 0.10 of minor B + 0.60 final exam.
c. Determine the equivalent grade for the numerical value obtained by the following
grading marks:
98-100 = 4.00
95-97 =3.75
Computing for the final grade of a student…
92-94 =3.50
89-91 =3.25 Student’s Name :> Jared
86-88 =3.00 Midterm Grade :> 100
Minor B :> 100
83-85 =2.75 Final Exam :> 100
80-82 =2.50
77-79 =2.25 Final Grade :> 100.00 (4.00)

74-76 =2.00
71-73 =1.75
68-70 =1.50
64-67 =1.25
60-63 =1.00
below 60=0.50

==========================================================================================
Write a Python code that prompts the user for two integers, reads them in and then
allows the user two choices: to compute the minimum of those two values or the
maximum. If the user inputs an invalid choice, set the result to 0. A sample dialog for
this program looks as follows:
Enter two integers: 8 35
Enter 1 for min, 2 for max: 1
Result = 8
==================================================================
Write a Python code that reads the lengths of three sides of a triangle and prints out the
classification of the triangle as follows:
invalid input: all sides must have lengths that are strictly positive
not a triangle: the sum of any two sides must be greater than the length of the
third
scalene triangle: no two sides have equal length
isosceles triangle: two sides (but not the third) are equal
equilateral triangle: all three sides are equal
Provide validation a l l data entries and ask if t h e user wants to try running again the
program.

Enter the three sides of a triangle: 2.5 2.5 2.5


IT’S AN EQUILATERAL TRIANGLE.

=====================================================

Given two numbers x and y, draw a flowchart to determine the difference between x
and y. If x – y is negative, compute R = x + y; if x – y is zero, compute R = 2x + 2y;
and if x – y is positive, compute R = x * y. Print the values of x, y and R.
=====================================================

Construct a flowchart that tasks for the amount purchased by the customer. If the
customer purchases more than 2,000 then a 5% discount is given. Display the net
amount to be paid by the customer.

A hotel has a pricing policy as follows:


a. 2 people: Php 2978.99
b. 3 people: Php 2575.99
c. 4 people: Php 2365.99
d. Additional people: Php 875 per person

If the customer is staying on company business, there is a 20% discount. If the


customer is over 60 years of age, there is a 15% discount. A customer does not
receive both discounts. Given the above data, print the cost of the room
====================================================
At Skul Bukol University, a student is enrolled in a course in which the final grade is
either a “P” or an “F”. The grade is determined by adding the scores obtained on
three tests: T1, T2, & T3. If the sum of the test scores is greater than 225, a grade of
“P” to be printed, otherwise, an “F” is printed. Design a Python code to read an input
record containing three test scores and print an appropriate grade.
====================================================
An admission charge for The Little Rep Theater varies according to the age of the
person. Develop a Python Code to print the ticket charge given the age of the person.
The charges are as follows:
a. Over 55: Pph 255 .00
b. 21–54: Php 385.00
c. 13–20: Php 245.00
d. 3–12: Php 125.00
e. Under 3: Free of charge
=====================================================

Write a Python code, given the type of vehicle (‘c’ for car, ‘b’ for bus; ‘t’ for truck) and
the hours a vehicle spent in the parking lot, determines the parking charge based on
the rates shown below:
Car Php 85 per hour
Bus Php 145 per hour
Truck Php 365 per hour
=========================================
Write a Python code that determines a student’s grade. It reads three test marks
(between 0 and 100) and calculates the student’s grade based on the following rules:
 If the average of marks is 90% or more, the grade is ‘A’.
 If the average of marks is 70% or more and less than 90%, it checks the third
marks. If the third marks are more than 90%, the grade is ‘A’, otherwise grade
is ‘B’.
 If the average of marks is 50% or more but less than 70%, it checks the
average of 2nd and 3rd marks. If their average is greater than 70%, the grade is
‘C’, otherwise it is ‘D’.
 If the average of marks is less than 50%, the grade is ‘F’
==========================================

Write a program that determines the quadrant, given an angle as shown in table:

Quadrant Range of Angle


1 1 – 89
2 91 – 179
3 181 – 269
4 271 – 359

Note: If the angle is exactly 0 it is not in any quadrant but lies on the positive x-axis;
if it is exactly 90, it lies on the positive y-axis; if it is exactly 180, it lies on the
negative x-axis; and if it is exactly to 270, it lies on the negative y-axis.
=====================================================
Write a Python code that computes the amount payable by an airline passenger on his
baggage based on the following table:
Weight Amount

≤ 20 kg Php 1300
Php 1300 + Php (700 per kilogram for each additional kilogram
> 20 kg and ≤ 40 kg
exceeding 20 kg).
> 40 kg Php 900 per kilogram
The program asks the user to enter the weight of his baggage. The program then
outputs the amount payable.
=====================================================

Write a Python code that prompts the user to input x, y coordinates of a point in a
Cartesian plane. The program should then output a message indicating whether point
is origin, is located on x or y axis or appears in a particular quadrant. For example:
(0,0) is on origin; (4,0) is on x-axis; (0, -3) is on y-axis
=====================================================

Das könnte Ihnen auch gefallen