5. Select the problems with the following pseudocode. Be very careful again here and make sure you understand local variables and scope. You can start by tracing from the Main method.
Module Main()
Display “welcome to the csc-115 pizza shop!”
Menu()
Display “you ordered a “+ pizzaChoice+ “ pizza”
End Module
Module Menu()
String pizzaChoice
Display “please enter what kind of pizza you want: “
Input pizzaChoice
Display “Are you sure? Please enter your pizza choice again”
String pizzaChoice
Input pizzaChoice
End Module
A. pizzaChoice module is not defined
B. pizzaChoice variable cannot be used in body of Main because it is local and not in the scope of main
C. pizzaChoice variable must be a numeric type
D. pizzaChoice variable is declared two times in the same scope.
Problems :
B. pizzaChoice variable cannot be used in body of Main because it is local and not in the scope of main
Display “you ordered a “+ pizzaChoice+ “ pizza”
Display statement in Main() module is using pizzaChoice variable but it is notdeclared in Main()
D. pizzaChoice variable is declared two times in the same scope.
String pizzaChoice
variable declaration is done two times in Menu() module which is invalid.
The other two statements
A. A. pizzaChoice module is not defined ---- pizzaChoice is a variable not a Module.
C. pizzaChoice variable must be a numeric type --- It is not necessary that pizzaChoice variable should be numeric only. It can be string datatype also.
So correct options are B and D.
Do ask if any doubt. Please upvote.
5. Select the problems with the following pseudocode. Be very careful again here and make sure...
1. What are the problems with the following pseudocode? Be careful here, this one is tricky! Module main() Number siblingAge = 12 Display “your “+siblingType+ “ has” yearsUntilAdult(siblingAge) Display “years until they are an adult” End Module Module yearsUntilAdult(Number inAge) Character siblingType = “sister” If inAge < 18 Then Display inAge - 18 Else Display 0 End If End Module A. yearsUntilAdult module call can not see variable siblingAge so siblingAge can not be used as input into the module...
Write the pseudocode below as a working Python program. Take a screenshot of your code and output and paste into your answer document. User input of ‘y’ or ‘Y’ should cause the loop to continue. // Constant for the commission rate // Declare as a global variable Constant Real COMMISSION_RATE = 0.10 Module main() // Local variable Declare String keepGoing = "y" // Calculate as many commissions // as needed. While...
Can anyone help me with rewriting my pseudocode? Below is the pseudocode, and after that is the completed program. Pseudocode: DISPLAY Login information PROMPT for username/password output "Enter Username" input userName output "Enter password: " input password //If successful, display information pertaining to the specific user, as well as prompt for logout IF User type 'quit' Exit Program VALIDATE User Credentials IF NOT Validated Check number of Invalid Attempts IF user attempts equal three THEN DISPLAY error message...
I have this code and need this to be written and applied with an array? How do I process this? Also What would I apply this with flowchart? Module main() Call getDailyProfit() Call calculateWeeklyProfit() Call main() Module getDailyProfit() // Declare all variables and establish the array Constant Real SIZE = 7 Declare String days[SIZE] = Sunday, Monday, Tuesday, Thursday. Friday, Saturday Declare Real days Declare Real number Declare Real Index //Prompt the user for profit information for Sunday Display “How...
I have this code and need this to be written and applied with an array? How do I process this? Also What would I apply this with flowchart? Module main() Call getDailyProfit() Call calculateWeeklyProfit() Call main() Module getDailyProfit() // Declare all variables and establish the array Constant Real SIZE = 7 Declare String days[SIZE] = Sunday, Monday, Tuesday, Thursday. Friday, Saturday Declare Real days Declare Real number Declare Real Index //Prompt the user for profit information for Sunday Display...
Write the Flowchart for the following programming problem based on the pseudocode below. Last year, a local college implemented rooftop gardens as a way to promote energy efficiency and save money. Write a program that will allow the user to enter the energy bills from January to December for the year prior to going green. Next, allow the user to enter the energy bills from January to December of the past year after going green. The program should calculate the...
Hello! I'm looking for help with this assignment. Complete a program in pseudocode and Python that performs the following tasks. Open the file called M4Lab1ii.py linked below these instructions in your M4 Content module in IDLE. Save as M4Lab1ii.py. Replace ii with your initials. [example for someone with the initials cc: M4Lab1cc.py] Complete Steps 1-7 as requested within the code’s comments. Run your program and test all four calculations, then exit the program. Save your program as M4Lab1ii.py using your...
Look at this partial class definition, and then answer questions a - b below: Class Book Private String title Private String author Private String publisher Private Integer copiesSold End Class Write a constructor for this class. The constructor should accept an argument for each of the fields. Write accessor and mutator methods for each field. Look at the following pseudocode class definitions: Class Plant Public Module message() Display "I'm a plant." End Module...
Write a Java Program that performs the following functionalities: and you can use if statements, cases, and string methods Enter a new main sentence Find a String Find all incidents of a String Find and Replace a String Replace all the incidents of a String Count the number of words Count a letter’s occurrences Count the total number of letters Delete all the occurrences of a word Exit The program will display a menu with each option above, and then...
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...