Concept explainers
Find the error in the following pseudocode.
Module main()
Declare Real mileage
Call getMileage()
Display "You've driven a total of " mileage , " miles. "
End Module
Module getMileage()
Display "Enter your vehicle's mileage."
Input mileage
End Module
Learn your wayIncludes step-by-step video
Chapter 3 Solutions
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (8th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Management Information Systems: Managing The Digital Firm (16th Edition)
SURVEY OF OPERATING SYSTEMS
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out with Python (4th Edition)
- Module main() // Local variables Declare Real lengthA, widthA, areaA Declare Real lengthB, widthB, areaB // Get the dimensions of rectangle A. Display "Enter the dimensions of Rectangle A." Call getRectangle(lengthA, widthA) // Get the dimensions of rectangle B. Display "Enter the dimensions of Rectangle B." Call getRectangle(lengthB, widthB) // Calculate the rectangle areas. Set areaA = lengthA * widthA Set areaB = lengthB * widthB // Compare the areas. If areaA > areaB Then Display "Rectangle A has the greater area." Else If areaB > areaA Then Display "Rectangle B has the greater area." Else Display "Both rectangles have the same area." End If End If End Module // The getRectangle module gets a rectangle's length and width from // the user and stores the input in the reference parameters length // and width. Module getRectangle(Real Ref length, Real Ref width)…arrow_forwardModule main() // Local variables Declare Integer gramsFat, calories // Get fat grams Set gramsFat = getFat() // Get calories Set calories = getCalories(gramsFat) // Show percent calories from fat Call showPercent(gramsFat, calories) End Module // The getFat function gets grams of fat Function Integer getFat () Declare Integer inputAmount // enter count Display “Enter grams of fat: “ Input inputAmount // validate rate While inputAmount < 0 Display “Quantity must not be less than 0!” Display “Enter a valid quantity.” Input inputAmount End While return inputAmount End Function // The getCalories function gets number of calories Function Integer getCalories(gramsFat) Declare Integer inputAmount, maxCalories Set maxCalories = gramsFat * 9 // enter count Display “Enter number of calories: “…arrow_forwardModule main() // Local variables Declare Real width, length, area // Get the rectangle's width and length. getRectangleSides(width, length) // Get the rectangle's area. Set area = calcArea(width, length) // Display the area. Display "The rectangle's area is ", areaEnd Module// The getRectangleSides module prompts the user for// a rectangle's width and length. The values are// stored in the reference parameters.Module getRectangleSides(Real Ref width, Real Ref length) // Get the rectangle's width. Display "Enter the rectangle's width." Input width // Get the rectangle's length. Display "Enter the rectangle's length." Input lengthEnd Module// The calcArea function accepts a rectangle's// width and length as arguments, and returns// the rectangle's area.Function Real calcArea(Real width, Real length) Return width * lengthEnd Function flowchart pleasearrow_forward
- 10. Each code example is incorrect. Indicate why! (2 errors each) 1. if (i=0)// //...code 2. for(;;)// //...code 3. public static void SquareIt(int a){// return a*a; } 4. while(1);// //...codearrow_forwardDirection : Make a guessing game program that will generate a random number and ask the user to guess the generated value with at most three (3) attempts: Problem/Required : The system should have the corresponding feature/s: Generate a random value between 1 to 10. Give the user at most 3 attempts to input a value between 1 to 10. Display “Higher” or “Lower” depending on the user’s input compared to the generated value. Display “Sorry, 3 attempts already.” after 3 incorrect attempts, “Congratulations! You got it in n attempt/s” Show the generated number.arrow_forwardProblem Description Write a JAVA program that will read all words from a passage and store them in BST. The program then will display a menu and perform the following task: Delete a word. If a word exists, update the word frequency otherwise print word not exist. Search a word. If a word exists, print the word and its frequency otherwise print not exist. Add a new word. If the word is in the passage, update its frequency. Print all words and their frequency in ascending order. Input The input of this program is a passage. A passage consists of N words and symbols. Symbols that will be considered in the passage are full stop (.), comma (,), question mark (?) and exclamation mark (!). The passage will have M unique words, where the M is less than or equal to N. Followed by the input code and the required data as specified in the sample input-output. Input Stay at home, stay safe and stay healthy. Practice social distancing at work and at home. Help reduce the risk of infection…arrow_forward
- Challenge task The distance a vehicle travels can be calculated as follows: distance = speed * time For example, if a vehicle starts a trip at 10 miles and travels 40 miles per hour for 4 hours, the distance traveled is 170 miles, the first 2 hours the distance=80+10=90, and the second one=160+10=170. Write a program which reads the speed of a vehicle (in miles per hour) and how many hours it has traveled. The program should then use a for loop to display the distance the vehicle has traveled for every 2 hours of that time period. 1 Roserio ףי Constraints Nonearrow_forward// main module Module main() // Local variables Declare Integer number // Get number Call getNumber(number) // display Roman numeral Select number Case 1: Display “I” Case 2: Display “II” Case 3: Display “III” Case 4: Display “IV” Case 5: Display “V” Case 6: Display “VI” Case 7: Display “VII” Case 8: Display “VIII” Case 9: Display “IX” Case 10: Display “X” Default: Display “Error: Invalid Number” End Select End Module // The getNumber module gets wall space and stores it // in the number reference variable. Module getNumber (Integer Ref number) Display “Enter an integer from 1 to 10: ” Input number End Module I want flowchart and pseudocode pleasearrow_forwardModule main() // Local variables Declare Real budget, spent = 0, amount // Get budgeted amount Call getBudget(budget) // Get amount spent Call getAmount(spent) // display values Call showSpending(budget, spent) End Module // The getBudget module gets amount budgeted for the month Module getBudget(Real Ref inputBudget) Display “Enter amount budgeted for the month: “ Input inputBudget End Module // The getAmount module gets amounts actually spent // terminates on entry of amount = 0 Module getAmount(Real Ref spent) Declare Real inputAmount Do Display “Enter an amount spent: “ Input inputAmount Set spent = spent + inputAmount Until inputAmount == 0 End Module // The showSpending module accepts budget and spent and tells // if over or under budget Module showSpending(Real budget, spent) Display "Budgeted: $", budget Display "Spent: $", spent If budget > spent then Display "Spending less than budget. VERY GOOD!” Else…arrow_forward
- Module main() // Local variables Declare Real centigrade, fahrenheit // Set centigrade For centigrade = 0 to 20 Call setFahrenheit(centigrade, fahrenheit) // display values Call showTemperatures(centigrade, fahrenheit) End For End Module // The setFahrenheit module calculates degrees fahrenheit // equivalent to centigrade. Module setFahrenheit(Real centigrade, Ref fahrenheit) Set fahrenheit = ((9 * centigrade) / 5) + 32 End Module // The showTemperatures module shows centigrade degrees // and shows corresponding Fahrenheit degrees Module showTemperatures(Real centigrade, fahrenheit) Display centigrade, " degrees centigrade = ", fahrenheit, “ degrees fahrenheit” End Module pseudocode, program analysis and flowchart please.arrow_forwardCourse Level Programming Assignment - Programming a Calculator using Python In this assignment you will write a computer program from scratch using the Python programming language. This program will function as a simple calculator. Objectives Write a simple Python program that performs arithmetic operations based on the user input Stage 1: A simple calculator Your calculator should provide the following arithmetic and control operations. Arithmetic Operations Addition (+) add(a,b) Subtraction (-) subtract(a,b) Multiplication (*) multiply(a,b) Division (/) divide(a,b) Power (^) power(a,b) Remainder (%) remainder(a,b) Control Operations Terminate (#) Reset ($) Write a function select_op(choice) to select the appropriate mathematics function based on the users selection. The behavior of the program should be as follows: The program should ask the user to specify the desired operation…arrow_forwardCourse Level Programming Assignment - Programming a Calculator using Python In this assignment you will write a computer program from scratch using the Python programming language. This program will function as a simple calculator. Objectives Write a simple Python program that performs arithmetic operations based on the user input Stage 1: A simple calculator Your calculator should provide the following arithmetic and control operations. Arithmetic Operations Addition (+) add(a,b) Subtraction (-) subtract(a,b) Multiplication (*) multiply(a,b) Division (/) divide(a,b) Power (^) power(a,b) Remainder (%) remainder(a,b) Control Operations Terminate (#) Reset ($) Write a function select_op(choice) to select the appropriate mathematics function based on the users selection. The behavior of the program should be as follows: The program should ask the user to specify the desired operation…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,