1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Montano1993 [528]
3 years ago
13

1. Write a class for time objects that store three integer values for hour, minute, and second. Also, write a program to test th

e functionality of your class. Make sure it does all of the following:
Create time objects with no values (default)

Create time objects with all three values (hour, minute, second)

Change the value for hour

Display military time

Display standard time

2. Define a class for an elevator that only services three floors. Your class must store variables for CurrentFloor (int), GoingUp (bool), and GoingDown (bool). Write a default constructor function for the class and two member functions: goUp() and goDown(). Write an elevator test program. Have the program execute the following steps using the methods in the class:

Start on the first floor.

Go to the second floor (don’t forget to update the Boolean variable GoingUp).

Go to the third floor

Go to the fourth floor (or at least try to)

Go back to the second floor

Go back to the first floor
Computers and Technology
1 answer:
Alla [95]3 years ago
6 0

Answer:

1.

class TIME

{

int hour , min , sec ;

public :

TIME()

{

hour=min=sec=0;

}

TIME( int h , int m , int s )

{

hour = h;

min = m;

sec = s;

}

void change ( int Hour)

{

hour = Hour;

}

void stdtime()

{

if(hour>12)

cout<<"The Standard time is"<<(hour-12)<<":"<<min<<":"<<sec<<"P.M\n";

else

cout<<"The Standard time is"<<hour<<":"<<min<<":"<<sec<<"A.M\n";

}

void miltime()

{

cout<<"The Military time is"<<hour<<":"<<min<<":"<<sec<<" hours\n";

}

};

void main()

{

TIME A , B(13,25,30);

A .stdtime();

A.change(23);

A.miltime();

B.stdtime();

B.change(9);

B.miltime();

}

2.

class elevator

{

int CurrentFloor;

int GoingUp;

int GoingDown;

public:

elevator()

{

CurrentFloor=0;

GoingUp=1;

GoingDown=-1;

}

elevator(int floor)

{

CurrentFloor=floor;

GoingUp=1;

GoingDown=-1;

}

void goUp(int y)

{

if( CurrentFloor>3)

cout<<"\nNO MORE FLOORS\n";

else

CurrentFloor=CurrentFloor+y*GoingUp;

}

void goDown(int x)

{

if(CurrentFloor<0)

cout<<"\nNO MORE FLOORS";

else

CurrentFloor=CurrentFloor+x*GoingDown;

}

};

void main()

{

elevator A(1);

A.goUp(1);

A.goUp(1);

A.goUp(1);

A.goDown(1);

A.goDown(1);

}

You might be interested in
// This class calculates a waitperson's tip as 15% of the bill public class DebugThree1 { public static void main(String args[])
DENIUS [597]

I added a decimal format to keep all decimals within the hundredths place. I also changed the calcTip method to void and the argument to a double. Void means the method doesn't return anything and changing bill to type double let's us pass numbers with decimals to the calcTip method. I hope this helps!

Download txt
4 0
3 years ago
Why does a HTML seen to work even when its broken? why does the code sometimes turn pink?
OverLord2011 [107]

the reason HTML seems to work even if it has syntax errors is due to browser having built in ways to parse the code meaning it will still show but most likely look way different then you would want.

the code may turn pink due to syntax errors

5 0
3 years ago
Write a function that takes in two parallel lists: a list of times (in increasing order), and a list of distance traveled by tha
Georgia [21]

Below is the function that takes two parallel lists;

List of times in increasing order and that of distance travelled by that point in time.

I put into consideration the instructions given in the question.

ANSWER;

def find_velocity(time, distance):

velocities = []

for i in range(1, len(time)):

velocities.append((distance[i] - distance[i - 1]) / (time[i] - time[i - 1]))

return velocities

times are = [1, 3, 5, 7]

distances are = [25, 29, 35, 70]

print(find_velocity(times, distances))

7 0
3 years ago
When performing actions between your computer and one that is infected with a virus, which of the following offers No risk of yo
daser333 [38]

Answer:

d

Explanation:

7 0
3 years ago
Mr. Yang is a doctor who regards video games as an effective means of staying fit. What type of game would he recommend to his p
LUCKY_DIMON [66]

wii sports, just dance, etc.

Explanation:

3 0
2 years ago
Other questions:
  • Which of the acronyms listed below refers to a series of basic hardware diagnostic tests performed by the startup BIOS after the
    13·1 answer
  • You just read a restaurant review on the internet of the newest restaurant in town. The writer of the article said the food was
    15·1 answer
  • What software development model focuses on improving the product in small steps each time through the cycle?
    14·2 answers
  • It chapter 2 pennywise
    13·1 answer
  • What is the square root of 1600 and 36 ?​
    6·1 answer
  • This is for being Weird!
    15·2 answers
  • Coment on this if your user starts with dida
    5·1 answer
  • Suppression of politically or socially unacceptable co
    5·1 answer
  • PowerPoint Online automatically saves your presentation to what Office Online application?
    10·1 answer
  • Compare and discuss between electromechanical and electronic era of computer​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!