Question

In: Computer Science

i need the pseudocode and python program for the following problem. Besides the user entering the...

i need the pseudocode and python program for the following problem.

Besides the user entering the number of books purchased this order, they are asked for the number of

points earned for the year before this order and the number of books ordered this year before this order.

There are bonus points awarded based on the number of books previously ordered and number ordered

now. These points should be added to the variable points:

Current order: 0 Previous Orders > 10 Add 1 to point total

Current order: 1, 2, or 3 Previous Orders > 10 Add 2 to point total

Current order: > 3 Previous Orders > 10 Add 5 to point total

// main module

Module main()

// Local variables

Declare Integer points

Declare Integer yearlyBooks

Declare Integer books

// Get numbers

Call getYearlyPoints(points)

Call getYearlyBooks(yearlyBooks)

Call getBooksPurchased(books)

// Display points earned

If books == 0

Display "0 points earned this order"

// Bonus check here

Display “Total points for the year”, points

Else If books == 1

Display "5 points earned this order"

Set points = points + 5

// Bonus check here

Display “Total points for the year”, points

Else If books == 2

Display "15 points earned this order"

Set points = points + 15

// Bonus check here

Display “Total points for the year”, points

Else If books == 3

Display "30 points earned this order"

Set points = points + 30

// Bonus check here

Display “Total points for the year”, points

Else

Display "60 points earned this order"

Set points = points + 60

// Bonus check here

Display “Total points for the year”, points

End If

End Module

// The getYearlyPoints module gets number of books purchased

// this year before this month

// and stores it in the number reference variable.

Module getYearlyPoints (Integer Ref number)

Display "How many points have you earned so far this year?"

Input number

End Module

// The getYearlyBooks module gets number of books purchased

// this year before this month

// and stores it in the number reference variable.

Module getYearlyBooks (Integer Ref number)

Display "How many books did you buy this year before this month?"

Input number

End Module

// The getBooksPurchased module gets number of books purchased

// this month

// and stores it in the number reference variable.

Module getBooksPurchased (Integer Ref number)

Display "How many books did you buy this month?"

Input number

End Module

NOTE: Using the variable name number in all three modules is perfectly legal

because they are each “local” to the module. In the first module the value of

number is returned to the variable points. In the second module it is returned to

the variable yearlyBooks. In the third it is returned to books.

Solutions

Expert Solution

*****This requires some effort so please drop a like if you are satisfied with the solution*****

pseudocode:

define a function getYearlyPoints

  1. print "How many points have you earned so far this year? "
  2. read an integer number from input
  3. return that number

define a function getYearlyBooks

  1. print "How many books did you buy this year before this month? "
  2. read an integer number from input
  3. return that number

define a function getBooksPurchased

  1. print "How many books did you buy this month? "
  2. read an integer number from input
  3. return that number

define main function

  1. declare an integer variable points and initialize it to 0
  2. declare an integer variable yearlyBooks and initialize it to 0
  3. declare an integer variable books and initialize it to 0
  • Function calls
  1. call getYearlyPoints store the return value in points variable
  2. call getYearlyPoints store the return value in yearlyBooks variable
  3. call getBooksPurchased store the return value in books variable3
  • Condition Checking
  1. if books is 0 then print 0 points earned this order if yearlyBooks is greater than 10 then add 1 to the points variable and print the total points earned this year and exit
  2. if books is 1 then print 5 points earned this order if yearlyBooks is greater than 10 then add 5 and additional 2 points to the points variable then print total points and exit
  3. if books is 2 then print 15 points earned this order add 15 to the points varibale if yearlyBooks is greater than 10 then add 2 points to the points variable and print total points and exit
  4. if books is 3 then print 30 points earned this order add 30 to the points variable if yearlyBooks is greater than 10 then add 2 points to the points variable and print total points and exit
  5. if books is greater than 3 then print 60 points earned this order add 60 to the points variable and if yearlyBooks is greater than 10 then add 5 points to the points variable then print total points and exit

Python code:

def getYearlyPoints():
    print("How many points have you earned so far this year? ")
    number = int(input())
    return number

def getYearlyBooks():
    print("How many books did you buy this year before this month? ")
    number = int(input())
    return number

def getBooksPurchased():
    print("How many books did you buy this month? ")
    number = int(input())
    return number

def main():
    points = 0
    yearlyBooks = 0
    books = 0
    points = getYearlyPoints()
    yearlyBooks = getYearlyBooks()
    books = getBooksPurchased()
    if (books == 0):
        print("0 points earned this order\n")
        if (yearlyBooks > 10):
            points += 1
        print("Total points for the year", points)
    elif (books == 1):
        print("5 points earned this order\n")
        points += 5
        if (yearlyBooks > 10):
            points += 2
        print("Total points for the year", points)
    elif (books == 2):
        print("15 points earned this order\n")
        points += 15
        if (yearlyBooks > 10):
            points += 2
        print("Total points for the year", points)
    elif (books == 3):
        print("30 points earned this order\n")
        points += 30
        if (yearlyBooks > 10):
            points += 2
        print("Total points for the year", points)
    else:
        print("60 points earned for this order\n")
        points += 60
        if (yearlyBooks > 10):
            points += 5
        print("Total points for the year", points)

if __name__ == "__main__":
    main()


Related Solutions

I need assistance on this problem in Pseudocode and in C++ Program Program 3: Give a...
I need assistance on this problem in Pseudocode and in C++ Program Program 3: Give a baby $5,000! Did you know that, over the last century, the stock market has returned an average of 10%? You may not care, but you’d better pay attention to this one. If you were to give a newborn baby $5000, put that money in the stock market and NOT add any additional money per year, that money would grow to over $2.9 million by...
I need assistance on this problem in Pseudocode and in C++ Program 1: Stay on the...
I need assistance on this problem in Pseudocode and in C++ Program 1: Stay on the Screen! Animation in video games is just like animation in movies – it’s drawn image by image (called “frames”). Before the game can draw a frame, it needs to update the position of the objects based on their velocities (among other things). To do that is relatively simple: add the velocity to the position of the object each frame. For this program, imagine we...
I need a python program and a flowchart please!! Problem #1:    How much should I...
I need a python program and a flowchart please!! Problem #1:    How much should I study outside of class?                         Issue: Your fellow students need help. This is their first year in college and they need to determine how many hours they need to study to get good grades. Study Hours Per Week Per Class                    Grade 15                                                           A 12                                                           B 9                                                             C 6                                                             D 0                                                             F Project Specifications: The user enters their full name and the number of...
i need a pseudocode for a program in java that will convert dollars into euros and...
i need a pseudocode for a program in java that will convert dollars into euros and japanese yen using the print and prinln methods an if, if -else, statement a switch statement a while statement utilizes the file class uses the random class and random number generator and uses at least three methods other than main
In Python, your program will read in a number (no need to prompt the user), and...
In Python, your program will read in a number (no need to prompt the user), and then reads in that number of lines from the terminal. Then the program should print an array of strings formatted in a nice regular box. So if the user inputs this: 5 Grim visaged war has smooth’d his wrinkled front And now, instead of mounting barded steeds To fright the souls of fearful adversaries He capers nimbly in a lady’s chamber To the lascivious...
Hello, I need some assistance on completing this program in Pseudocode and in C++ Program 2:...
Hello, I need some assistance on completing this program in Pseudocode and in C++ Program 2: Buh-RING IT! For this assignment, you’re going to simulate a text-based Role-Playing Game (RPG). Design (pseudocode) and implement (source) for a program that reads in 1) the hero’s Hit Points (HP – or health), 2) the maximum damage the hero does per attack, 3) the monster’s HP and 4) the maximum monster’s damage per attack. When the player attacks, it will pick a random...
I need to write a program in python for a restaurant. The program should let the...
I need to write a program in python for a restaurant. The program should let the user enter a meal number, then it should display the meal name, meal price, and meal calories. Also, needs the appropriate output if the user enters an invalid meal number. I am supposed to use a dictionary, but my problem is it keeps giving me an error and telling me my menu is not defined. Not sure what I am doing wrong. print ("Welcome...
I need a pseudocode and UML for this program. import java.util.Random; public class SortandSwapCount {   ...
I need a pseudocode and UML for this program. import java.util.Random; public class SortandSwapCount {    public static void main(String[] args) {        //Generate random array for test and copy that into 3 arrays        int[] arr1=new int[20];        int[] arr2=new int[20];        int[] arr3=new int[20];        int[] arr4=new int[20];        Random rand = new Random();        for (int i = 0; i < arr1.length; i++) {            //Generate random array...
Task 1. creating a nested if:   Need a python program that ask the user to enter...
Task 1. creating a nested if:   Need a python program that ask the user to enter the annual income of an employee and the years of experience. Pass these data to a function. The function decides if an employee does qualify for a loan or does not, then it prints a message based on the following rules: If the income is equal or greater than $40000, the function checks if the employee's years of experience is greater than 4, if...
Need this program in python. The data must be taken from user as input. Write a...
Need this program in python. The data must be taken from user as input. Write a program that prompts the user to select either Miles-to-Kilometers or Kilometers-to-Miles, then asks the user to enter the distance they wish to convert. The conversion formula is: Miles = Kilometers X 0.6214 Kilometers = Miles / 0.6214 Write two functions that each accept a distance as an argument, one that converts from Miles-to-Kilometers and another that converts from Kilometers-to-Miles The conversion MUST be done...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT