Question

ATTENTION!!!

Please answer this in details and put briefly explanation.

THANK YOU!

Objective is to create pseudo-code to implement a simple cruise control for a car. Write a single function called TestCruisel

Just pseudo code. It can be C programming

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

thanks for the question, here is the C program with comments against each code line

==========================================================================================

#include<stdio.h>

// this is the setpoint we will compare the current speed
// to the desired speed

double const DESIRED_SPEED=80;
// lets assume the current vehicle speed is 100 km/hr
double GetVehicleSpeed() {
double vehicleSpeed = 100;
return vehicleSpeed;
}

// if the current speed is equal to the desired speed we return 0
// if the current speed is greater than desired speed the function return 1
// if the current speed is less than the desired speed the function return -1


int TestCruise(double current_speed) {
if(current_speed==DESIRED_SPEED) {
return 0;
} else if(current_speed>DESIRED_SPEED) {
return 1;

} else {
return -1;
}
}

int main() {
// calls Test Cruise to return the current status
double current_speed = GetVehicleSpeed();
int status = TestCruise(current_speed);
// if the return value is 0, that means both current and desired speed are same
// we print Speed OK
if(status==0) {
printf("Speed OK");
// if the status is 1, that means the current speed is more than the desired speed
// abd we print decelarted needed
} else if(status==1) {
printf("Need Decelerate");
// else it means the current speed is less than desired speed and needs acceleration
} else {
printf("Need Accelerate");
}

}

==========================================================================================

Add a comment
Know the answer?
Add Answer to:
ATTENTION!!! Please answer this in details and put briefly explanation. THANK YOU! Just pseudo code. It...
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
  • Please Use C++ Language. Thank you. Please I need the actual code. Donot post psudocode!! ​And...

    Please Use C++ Language. Thank you. Please I need the actual code. Donot post psudocode!! ​And also I have codes but just donot work so make sure that it works. Requested files: CrosswordGenerator.cpp, CrosswordGenerator.h, CrosswordGenerator_test.cpp CrosswordGenerator - Write a program that helps to generate a crossword puzzle by organizing words that share letters.   For this assignment, you will write a program that forms the basis of a crossword puzzle generator. In order to create a crossword puzzle you need to...

  • Please write the code in a text editor and explain thank you! 1. LINKED-LIST: Implement a...

    Please write the code in a text editor and explain thank you! 1. LINKED-LIST: Implement a function that finds if a given value is present in a linked-list. The function should look for the first occurrence of the value and return a true if the value is present or false if it is not present in the list. Your code should work on a linked-list of any size including an empty list. Your solution must be RECURSIVE. Non-recursive solutions will...

  • Help with programming in C++ Phase 1 is complete, please help with phase 2. Thank you....

    Help with programming in C++ Phase 1 is complete, please help with phase 2. Thank you. Phase 1 You must design 3 algorithms, and provide both a flow chart and pseudo code for the algorithms.    Algorithm descriptions: Given an integer parameter named current_number and two constant global variables: const int MIN_NUMBER = 1; const int MAX_NUMBER = 8; Create an algorithm named forward, that will advance ONE value through a sequence of numbers 1, 2, 3 ... MAX_NUMBER. In...

  • Please answer read the question first, don't just copy the answer from other websites, thank you...

    Please answer read the question first, don't just copy the answer from other websites, thank you very much. and this is a c++ problem. 17.Given the following class definitions class Deque; class DequeNode friend class Deque; private: int data; DequeNode *prev; DequeNode *next; class Deque private: DequeNode *head; int number; DequeNode *tail; public: Deque ) Deque() void push front (const int &); void push back (const int &) int front () int back ) int pop front ); int pop...

  • Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solu...

    Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solutions. Instructions 1. Read instructions carefully! 2. Use C++ syntax only, C syntax will not be accepted. 3. Always use braces to define blocks. 4. Indent all lines within a block. Each block requires one more tab. 5. Organize your code well with proper formatting and a single...

  • Code in c++ please. Does not have to be complete, just write code for the ones you know. Thank y...

    Code in c++ please. Does not have to be complete, just write code for the ones you know. Thank you. template <typename T> class smart_ptr { public: smart_ptr(); // Create a smart_ptr that is initialized to nullptr. The reference count // should be initialized to nullptr. explicit smart_ptr(T* raw_ptr); // Create a smart_ptr that is initialized to raw_ptr. The reference count // should be one. smart_ptr(const smart_ptr& rhs); // Copy construct a pointer from rhs. The reference count should be...

  • please Answer in Details showing all the steps. Thank you Look at the following reaction: Toluene...

    please Answer in Details showing all the steps. Thank you Look at the following reaction: Toluene OH + CH3OH OCH3 + H2O a) What is the effect of each of the given changes (see next page) on the rate of the reaction? The possible answers are: Increases, decreases, remains the same or no more reaction. 1- Decreasing the concentration of CH,OH 2-Using a Dean-Stark apparatus (used to remove water from the reaction mixture) 3- Adding H,SO, to the reaction mixture...

  • I need the following written in Java please, thank you ' We want you to implement...

    I need the following written in Java please, thank you ' We want you to implement a java class that will show details on users and throw exceptions where needed. The following requirements specify what fields you are expected to implement in your User class: - A private String firstName that specifies the first name of the user - A private String lastName that specifies the last name of the user - A private int age that specifies user's age...

  • The Code need to be in C# programming language. could you please leave some explanation notes...

    The Code need to be in C# programming language. could you please leave some explanation notes as much as you can? Thank you Create the following classes in the class library with following attributes: 1. Customer a. id number – customer’s id number b. name –the name of the customer c. address – address of the customer (use structs) d. telephone number – 10-digit phone number e. orders – collection (array) of orders Assume that there will be no more...

  • Write a program that demonstrates use of programmer - defined data structures. Please provide code! Thank...

    Write a program that demonstrates use of programmer - defined data structures. Please provide code! Thank you. Here are the temps given: January 47 36 February 51 37 March 57 39 April 62 43 May 69 48 June 73 52 July 81 56 August 83 57 September 81 52 October 64 46 November 52 41 December 45 35 Janual line Iranin Note: This program is similar to another recently assigned program, except that it uses struct and an array of...

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