Question

(16 minutes) The function below has 4 errors. It has two integer parameters representing the time in hours and minutes. It sh
0 0
Add a comment Improve this question Transcribed image text
Answer #1

4 errors:

Line num 1 has two errors: It should be

int addMinute(int hour,int minute)

First Error: Function is returning something, so its not void, it should be int.

Second Error: It should not be &minute in the paramenter, just int minute would do the job

Line number 6 has one error:

else{

minute = 0;

hour++;

}

Third error:As the else clause contains two statements, it should have brackets to surround it.

Line number 10 has an error: It should be

int total = hour*60+minute

Fourth error: Variable total should be defined as int before using it.

Correct Code:

int addMinute(int hour, int minute){
   if(minute<59)
   minute++;
   else{
   minute = 0;
   hour++;
   }
int total = hour*60+minute;
return total;
}

Comment in case of any doubt. Good luck.

Add a comment
Know the answer?
Add Answer to:
(16 minutes) The function below has 4 errors. It has two integer parameters representing the time...
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
  • Write in C++ please In Chapter 10, the class clockType was designed to implement the time...

    Write in C++ please In Chapter 10, the class clockType was designed to implement the time of day in a program. Certain applications, in addition to hours, minutes, and seconds, might require you to store the time zone. Derive the class extClockType from the class clockTypeby adding a member variable to store the time zone. Add the necessary member functions and constructors to make the class functional. Also, write the definitions of the member functions and the constructors. Finally, write...

  • Need help with this java code supposed to be a military time clock, but I need...

    Need help with this java code supposed to be a military time clock, but I need help creating the driver to test and run the clock. I also need help making the clock dynamic. public class Clock { private int hr; //store hours private int min; //store minutes private int sec; //store seconds public Clock () { setTime (0, 0, 0); } public Clock (int hours, intminutes, int seconds) { setTime (hours, minutes, seconds); } public void setTime (int hours,int...

  • use matlab to solve it 1. Write a function called MyTimeConversion with the following function declaration...

    use matlab to solve it 1. Write a function called MyTimeConversion with the following function declaration line. begin code function [Hours, Minutes, Message] = MyTimeConversion (TotalMinutes) end code The input argument TotalMinutes should be a nonnegative scalar integer representing the total number of minutes in a specified time interval. The output arguments Hours and Minutes should be nonnegative scalars such that Hours*60 + Minutes = TotalMinutes and the value of Minutes must be less than 60. The output argument Message...

  • I need help implementing class string functions, any help would be appreciated, also any comments throughout...

    I need help implementing class string functions, any help would be appreciated, also any comments throughout would also be extremely helpful. Time.cpp file - #include "Time.h" #include <new> #include <string> #include <iostream> // The class name is Time. This defines a class for keeping time in hours, minutes, and AM/PM indicator. // You should create 3 private member variables for this class. An integer variable for the hours, // an integer variable for the minutes, and a char variable for...

  • Debugging: The code below has six errors. The errors may be syntax errors or logic errors,...

    Debugging: The code below has six errors. The errors may be syntax errors or logic errors, and there may be more than one per line; examine the code carefully to find them. Indicate each of the errors you find by writing the line number and correction in the space provided below. This program is designed to take a constant number of scores (3 in this case) and store them into an array. Then the array is passed to a function...

  • i need #6 but i believe #6 function needs to call #5 function. I would like...

    i need #6 but i believe #6 function needs to call #5 function. I would like this in C language, and have no pointers, arrays or strings (on function calling and parameters). Thanks! I have attached the other functions that you might need to call for function 6 1. Write and test a function called is_multiple_of that takes a integer n1, integer n2 and determines whether the second argument (n2) is a multiple of the first argument (n1). The function...

  • Define a function named food which receives two parameters: an integer value representing the time of...

    Define a function named food which receives two parameters: an integer value representing the time of the day measured in hours from 0 to 24 and a Boolean value indicating whether a person likes sweets (True) or not (False). The function should return one single string with a message as follows. If it is earlier than 6, the message should say "no food" (regardless of the person liking sweets or not). If it is between 6 and 10 extremes included,...

  • help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and...

    help ASAP 3. Write a string C++ function named UnsignedPartialSum() that takes two string parameters and an int parameter. If both string parameters represent binary numbers and the int parameter is equal to a positive number less than or equal to the length of the longest string parameter, the function should return a binary string whose length is equal to two times the length of the maximum length of the two string parameters whose value is equal to the sum...

  • need help with this JAVA lab, the starting code for the lab is below. directions: The...

    need help with this JAVA lab, the starting code for the lab is below. directions: The Clock class has fields to store the hours, minutes and meridian (a.m. or p.m.) of the clock. This class also has a method that compares two Clock instances and returns the one that is set to earlier in the day. The blahblahblah class has a method to get the hours, minutes and meridian from the user. Then a main method in that class creates...

  • Assignment 4 - Time Comparable For this assignment, you will be updating the Time class from...

    Assignment 4 - Time Comparable For this assignment, you will be updating the Time class from Assignment 1. To get started, you can either make a copy of your Assignment 1 Time.java, or download the solution, Time.java. This is Assignment 1: --------------------------- public class Time { private int h; private int m; public Time() { super(); } public Time(int h, int m){ if(h>=1 && h<=23){ this.h = h; }else{ this.h = 0; } if(m>=0 && m<=59){ this.m = m; }else{...

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