Question

In: Computer Science

  Module Main ()                                       &nbsp

  1.   Module Main ()                                                  
  2.         // Create a car object
  3.         Declare car myCar
  4.         // Call the constructor of the car and set the                         
  5.         // variables      
  6.         Set myCar = New Car (2020, “Lexus LX 480”, 5)
  7.          // Call the accelerate method five time
  8.          Call myCar.accelerate ()
  9.          // Call the getSpeed method to get current speed
  10.         // of the car       
  11.         Display “The Speed of the car is: “, myCar.getSpeed ()                                            
  12.                 
  13.         Call myCar. accelerator   
  14.         Display “The speed of the car is: “, myCar.getSpeed ()
  15.      
  16.         Call myCar. accelerator   
  17.         Display “The speed of the car is: “, myCar.getSpeed ()
  18.         Call myCar. accelerator   
  19.         Display “The speed of the car is: “, myCar.getSpeed ()
  20.         Call myCar. accelerator   
  21.         Display “The speed of the car is: “, myCar.getSpeed ()
  22.         // Call the brake method five times
  23.         Call myCar.brake ()
  24.         // Call the getSpeed method to get the current speed
  25.         // of the car
  26.         Display “The speed of the car is: “, myCar.getSpeed()
  27.        Call myCar.brake()        
  28.       Display “The speed of the car is: “, myCar.getSpeed()                                 
  29.        Call myCar.brake()        
  30.       Display “The speed of the car is: “, myCar.getSpeed()
  31.     
  32.        Call myCar.brake()        
  33.       Display “The speed of the car is: “, myCar.getSpeed()
  34.        Call myCar.brake()        
  35.       Display “The speed of the car is: “, myCar.getSpeed()
  36. End Module     

I need a Flowchart for the above psuedocode. Thank You?

Solutions

Expert Solution

Above pseudocode is in OOP concept :

A class Car is defined having 1 constructor and 3 methods :

Constructor is parameterized to set the values of variables , as variables are not shown in program we are not aware of names for same .

Contructor have 3 parameters which sets the values of data members inside Car class.

Constructor name is same as that of Class name.

Syntax:

Car()

Three methods are also declared:

1. getSpeed ()

2. accelerate ()

3. brake()

All are public methods , accessible outside the class , as well , " + " symbol is used to show the methods are public

Main function in the program to execute the program

Firstly, object of class Car is declared

Constructor is called to initialize/set the values

accelarate() function of class Car is called five times

And speed() function is called five times in the print statement to print speed value

This is done by FOR loop by giving initializing variable i to 0 ,condition i<5 and incremented i by 1

After that,  brake() function of class Car is called five times

And speed() function is called five times in the print statement to print speed value

This is done by FOR loop by giving initializing variable i to 0 ,condition i<5 and incremented i by 1

Functions of class is called by declaring object for that class and dot operator with function name

Class diagram for Class Car:

Flowchart of main function with comments:

Note: Flowchart for functions of class is not constructed as details are not mentioned in the question


Related Solutions

put a loop around the main module that will ask the user if they want to...
put a loop around the main module that will ask the user if they want to run the program again with another week of lemonade and cookie sales. def main():    # constants given CUP_COST= .05 LEMONADE_MIX_OZ_COST =.10 COSTOFCOOKIES = .11 COOKIESALE = .25 #inputs numberOfCupsUsed=int(input('Enter the number of cups used this week ')) ouncesOfMixUsed=int(input('Enter ounces of Lemonade mix used ')) salesForWeekLemonade=float(input('Enter total Lemonade sales for the week $')) cookiesSoldForWeek = int(input("Enter number of cookies sold for the week: "))...
Create and submit a Python program (in a module) that contains a main function that prints...
Create and submit a Python program (in a module) that contains a main function that prints 17 lines of the following text containing your name: Welcome to third week of classes at College, <your name here>! can someone please show me how to do this step by step? I'm just confused and keep getting errors in idle.
Address the following, which cover the main objectives for this module: Summarize the differences that exist,...
Address the following, which cover the main objectives for this module: Summarize the differences that exist, if any, between the US GAAP and IFRS on the accounting for derivatives designated as hedges at the current date you are answering this question. Prepare an example of a U.S.-based firm managing an exposed foreign currency net liability position including the journal entries required from the date the U.S. firm purchases goods on account from a foreign-based supplier until the date the purchase...
assume that the following pseudocode is executed in a program module main declare x = 1...
assume that the following pseudocode is executed in a program module main declare x = 1 declare sum = 0 declare max = 5 while ( x < max) Display "x is ", x set x = x + 1 set sum = s + x end while end module after the execution of this program the final value of x is_____ and the final value of sum is_____
Question 3 A java source module contains the following class with the static methods main and...
Question 3 A java source module contains the following class with the static methods main and procedure1, and the instance method procedure2 (assume given the bodies of procedure1 and procedure2): public class TestQuestion3             {                         static int result, num1 = 10;                         public static void Main( String [ ] args )                         {                                     int [ ] list1 =   { 2, 4, 6, 8, 10}, list2;                                     .    .    .                         }                         static void procedure1( void )                         {                                     .   .   .                         } void procedure2( void )...
Module - Management Accounting The main role of Management Accounting is: Planning Control and Decision making....
Module - Management Accounting The main role of Management Accounting is: Planning Control and Decision making. Decision making is the selection of the correct cost element and take the right decision in the best interest of the organization be: -Make or buy decision -Accept or reject decision -Shut down decision -Limiting factor decision In relation to Decision making explain the above statement. It should include limiting factor with several constraint and making use of linear programing technique). Word limit-1500
Summarise the Mass Transfer module for Chemical Engineering, list all the main equations, and basic definitions....
Summarise the Mass Transfer module for Chemical Engineering, list all the main equations, and basic definitions. (Mass transport/ diffusion/ steady states / flux/ficks laws 1st/2nd, laminar turbulent, volume flow rate, dispersion, pore diffusion, film theory, absorption, distillation,)
Module 7 Worksheet (Muscles) BIO 326 1. What are the three main muscle types and describe...
Module 7 Worksheet (Muscles) BIO 326 1. What are the three main muscle types and describe their characteristics (striated or not, duration of muscle twitch, purpose). b. Describe how skeletal muscle contracts. What ion is important and what happens when it increases in abundance inside the cell? How does the muscle relax again? c. Why do t-tubules need to be closely associated with the sarcoplasmic reticulum? d. Describe how the pacemaker (auto rhythmic) cells generate a repetitive series of action...
Write a Class called Module with the following attributes: module code, module name, list of lecturers...
Write a Class called Module with the following attributes: module code, module name, list of lecturers for the module (some modules may have more than one lecturer – we only want to store their names), number of lecture hours, and module description. Create a parameterised (with parameters for all of the class attributes) and a non-parameterised constructor, and have the accessor and mutator methods for each attribute including a toString method. Write a class Student with the following attributes: student...
main() module Display "Welcome to my Guess the number program!" while true display_menu() Get input if(option==1)...
main() module Display "Welcome to my Guess the number program!" while true display_menu() Get input if(option==1) user_guess() elif(option==2) computer_guess() else break user_guess() module random mynumber count=1 userGuesses=[] while True try Display "Guess a number between 1 and 10" Get guess while guess<1 or guess>10 Display "Guess a number between 1 and 10" Get guess except Display "numbers only" continue userGuesses.append(guess) if (guess<mynumber) Display "Too low" count=count+1 else if (guess>mynumber) Display "Too high" count=count+1 else if (guess==mynumber) Display "You guessed it...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT