Question

6. Write a program (compile and run), a pseudocode, and draw a flowchart for each of...

6. Write a program (compile and run), a pseudocode, and draw a flowchart for each of the following problems:

a) Obtain three numbers from the keyboard, compute their product and display the result.

b) Obtain two numbers from the keyboard, and determine and display which (if either) is

the smaller of the two numbers.

c) Obtain a series of positive numbers from the keyboard, and determine and display their average (with 4 decimal points). Assume that the user types the sentinel value -1 to indicate “end of data entry.”

0 0
Add a comment Improve this question Transcribed image text
Answer #1

# Answer a)   

# Pseudocode

#
# 1. Take three numbers from user A, B, C
# 2. D = A*B*C
# 3 Print(C)
#

# python Function that impliments above Pseudocode
def computProduct():
A=int(input("Enter A: "))
B=int(input("Enter B: "))
C=int(input("Enter C: "))
D=A*B*C;
print(D)

# Answer b)
# Pseudocode

# 1. Take Two numbers from user A,B
# 2. if A>B then,
# display(A is greater)
# else if B>A then,
# display(B is greater)
# else display(both are equal)
# end if
# python function that impliments above Pseudocode
def determineGreater():
A= int(input("Enter A: "))
B= int(input("Enter B: "))
  
if(A>B):
print("{} is greater than {}".format(A,B))
elif(B>A):
print("{} is greater than {}".format(B,A))
else:
print("Both are equal")

# Answer c)
# Pseudocode

# 1. counter =0, sum =0
# take input from user
# 2. loop while userInput is not -1
# sum = sum + userInput
# counter = counter +1
# take input from user
# 3. end loop
# 4. if counter is not 0
# average = sum/counter
# display(average rounded upto 4 decimal places)
# else
# display(0)

# Python program that impliments above Pseudocode
def computAverage():
counter =0
sum = 0
userinput =int(input("Enter a positive number: "))
while(userinput !=-1):
sum = sum+ userinput
counter = counter +1
userinput = int(input("Enter a positive number: "))
if counter !=0:
average = sum/counter
print(round(average,4))
else:
print(0)
  
# test our code
computProduct()
determineGreater()
computAverage()

Florochaut (Comput the product of towe numbers) start Read A, B, C D = A*B*c Brent ED T end Flow chart of Compute the largerFlow Chart (Eind the average) enprata- No SunSummet Read euput - I Display o contocor No Laverge= Sumplanta T Thusplay lever

Add a comment
Know the answer?
Add Answer to:
6. Write a program (compile and run), a pseudocode, and draw a flowchart for each of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Draw a flowchart or write pseudocode to represent the logic of a program that allows the user to enter two values

    # C++ Draw a flowchart or write pseudocode to represent the logic of a program that allows the user to enter two values. The program outputs the sum of and the difference between the two values.

  • Write an Algorithm in Pseudocode for the Exercises Below Add 5 numbers that a user enters...

    Write an Algorithm in Pseudocode for the Exercises Below Add 5 numbers that a user enters by keyboard and display the Total on screen. Compute the area of a rectangle and display on screen based on length and width values that the user enters by keyboard. Compute the new price for a product that’s on sale for 10% off. Display new calculated price on screen. Assume current price is $25.00. Add the prices of an order of fries, a burger...

  • programming in Microsoft visual studio. Write a C++ program for the following algorithm. Compile, run, and...

    programming in Microsoft visual studio. Write a C++ program for the following algorithm. Compile, run, and verify the result by choosing some test data. Prompt user to write X1 value in double Read X1 Prompt user to write X2 value in double Read X2 Prompt user to write Y1 value in double Read Y1 Prompt user to write Y2 value in double Read Y2 Compute the lengths of the two sides of the right triangle generated by the two points...

  • Pseudocode and Flowchart: Program that stops production whenever there is a run of four consecutive pills...

    Pseudocode and Flowchart: Program that stops production whenever there is a run of four consecutive pills that have a content of Ibuprofen above, or four consecutive pills with a level below 129. Also use these two modules in your code: machineOFF()is a module that turns off the machine when is executed. getIbuprofen()is a module that returns the value of Ibuprofen from the current pill or 0 if this is the last pill. Please make sure to use the following additional...

  • Requirement Write pseudocode and translate it to ONE C-program for each the following problems. In your...

    Requirement Write pseudocode and translate it to ONE C-program for each the following problems. In your pseudocode and C-program, use only what you have learned in this class so far. (Menu) Design a menu for question 2 and 3. So far, you use one program to solve all lab questions. But some of you may feel awkward when you want to demo/test only one lab question. To overcome that, your program should show a menu so that the users of...

  • (write algorithm and draw flowchart) for this question Write a C program which has a function...

    (write algorithm and draw flowchart) for this question Write a C program which has a function that takes two numbers and find the largest and the smallest number and find the result of the largest power of smallest.(for example If the entered numbers are 6 and 3 the result is 6³)

  • Q4. Write an algorithm, draw the flowchart and write a C++ program to • Read the...

    Q4. Write an algorithm, draw the flowchart and write a C++ program to • Read the Number and Letter from the user • Check the number and letter then print the corresponding month name as given in Table Q4 using IF ELSE STATEMENT. Table: Q4 Number and Letter Month Name JANUARY 2 F FEBRAURY 3 M MARCH 4 A APRIL Other numbers Invalid Input 1J Sample Output: Enter the value of number:1 Enter the value of letter:) JANUARY Algorithm: Flowchart:...

  • Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve...

    Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve the following program. -Use Microsoft Visual C++ .NET 2010 Professional compiler using default compiler settings. -Use Microsoft Visio 2013 for developing your flowchart. -Adherence to the ANSI C++  required -Do not use <stdio.h> and <conio.h>. -Do not use any #define in your program. -No goto statements allowed. Upon execution of the program, the program displays a menu as shown below and the user is prompted to make a selection from the menu....

  • 6. Consider a C program that reads two real numbers from the keyboard followed by a character where the character can b...

    6. Consider a C program that reads two real numbers from the keyboard followed by a character where the character can be one of the operators +,-, *, 1, or % providing the addition, subtraction, multiplication, division, or remainder respectively. Then the result is displayed on the screen For example, if the user types 2.0 3.0 % then your code will display: Note: In the above example the inputs are real numbers but the remainder only performs an integer operation....

  • Write a C program that asks the user to enter two real numbers. Then your program...

    Write a C program that asks the user to enter two real numbers. Then your program displays a menu that asks the user to choose what arithmetic operation to be done on those numbers. Depending on the user's entry, the program should display the result to the screen. The sample runs below show what should be done to the numbers entered by the user. Your program should run exactly like shown in the sample runs. make your code run as...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT