How would I loop this so that I can test out the times 1730 and 0900 and the reverse, 0900 and 1730? Preferably a "do, while" loop if possible?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
cout << "Please enter your last name " << endl;
cin >> name;
cout << "Welcome, " << name << endl;
//Variables that are being declared
int time1;
int time2;
int timeDifference;
int min;
int hrs;
//Time inputs
cout << "Please enter the first time: ";
cin >> time1;
cout << "Please enter the second time: ";
cin >> time2;
//Time conversion
if (time2 < time1)
{
time2 = time2 + 2360;
}
timeDifference = time2 - time1;
hrs = timeDifference / 100;
min = timeDifference % 100;
hrs = hrs + min / 60;
min = min % 60;
cout << hrs << " hours " << min << " minutes ";
system("pause");
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main() {
string name;
cout << "Please enter your last name " << endl;
cin >> name;
cout << "Welcome, " << name << endl;
//Variables that are being declared
int time1;
int time2;
int min;
int hrs;
//Time inputs
cout << "Please enter the first time: ";
cin >> time1;
cout << "Please enter the second time: ";
cin >> time2;
//Time conversion
if (time2 < time1) {
time2 = time2 + 2360;
}
hrs = (time2 / 100) - (time1 / 100);
min = (time2 % 100) - (time1 % 100);
if(min >= 60) {
min -= 60;
hrs++;
}
cout << hrs << " hours " << min << " minutes ";
return 0;
}
please upvote.

How would I loop this so that I can test out the times 1730 and 0900...
So Im here and im stuck. I need to figure out how to get the
character of the first name to be printed on a separate line and
the middle and last. is there a way where i can tell a my function
to stop once it hit " "? Please help.
I #include iostream 2 #include string using namespace i; string name 7 getline cin, name 4 int main ) cout<"Please enter your full name: " problem3.cpp 3Write a...
My if/else statement wont run the program that I am calling. The menu prints but once I select a number the menu just reprints, the function called wont run. What can I do to fix this probelm? #include <iostream> #include "miltime.h" #include "time.h" #include "productionworker.h" #include "employee.h" #include "numdays.h" #include "circle.h" using namespace std; int main() { int select=1; while (select>0) { cout << "Option 1:Circle Class\n"<< endl; cout << "Option 2:NumDay Class\n" << endl; cout <<"Option 3:Employee and Production...
How can I modify the program below with this prompt asking "How
many minutes from now do you expect to be home?", and output a
sentence saying "You will get home at HH:MM". ??
It's very URGENT!! Thank you
#include <iostream> #include <ctime> using namespace std; int main) time t t struct tm *now t-time (e) now-localtime(&t); int hour = now->tm.hour; // retrieve current hour int min = now->tm..min; // retrieve current min // get current time // adjust for...
What does this error message mean? "expected primary expression before int" Also, how do i get the program to repeat the numbers that were entered by the user back to me? this is my code below: // This program accepts a series of positive numbers // This code was last modified on 2/16/2020 #include <iostream> #include <iomanip> #include <cmath> using namespace std; void welcome(); int entrySubmission(int numbers); void acceptsNumbers(int); void goodbye(); int main() { welcome(); entrySubmission(int numbers); acceptsNumbers(int); goodbye(); return...
Convert to use functions where possible #include<iostream> #include<string> using namespace std; int main() { string first, last, job; double hours, wages, net, gross, tax, taxrate = .40; double oPay, oHours; int deductions; // input section cout << "Enter First Name: "; cin >> first; cout << "Enter Last Name: "; cin >> last; cin.ignore(); cout << "Enter Job Title: "; getline(cin, job); cout << "Enter Hours Worked:...
I have a program that needs comments added to it: #include <iostream> #include <stdio.h> #include <conio.h> #include <windows.h> using namespace std; int main() { int m, s,h; cout << "A COUNTDOWN TIMER " << endl; cout << "enter time in hours here" << endl; cin >> h; cout << "enter time in minutes here " << endl; cin >> m; cout << "enter time in seconds here" << endl; cin >> s; cout << "Press any key to start" <<...
How could I separate the following code to where I have a gradebook.cpp and gradebook.h file? #include <iostream> #include <stdio.h> #include <string> using namespace std; class Gradebook { public : int homework[5] = {-1, -1, -1, -1, -1}; int quiz[5] = {-1, -1, -1, -1, -1}; int exam[3] = {-1, -1, -1}; string name; int printMenu() { int selection; cout << "-=| MAIN MENU |=-" << endl; cout << "1. Add a student" << endl; cout << "2. Remove a...
C++ Language I have a class named movie which allows a movie object to take the name, movie and rating of a movie that the user inputs. Everything works fine but when the user enters a space in the movie's name, the next function that is called loops infinetly. I can't find the source of the problem. Down below are my .cpp and .h file for the program. #include <iostream> #include "movie.h" using namespace std; movie::movie() { movieName = "Not...
15.6: Fix the code to print the count from 1 to x (to loop x times) #include <iostream> // include the header file using namespace std; void count(int x){ for(int i=1; i<=x; i++){ cout<<x; } } int main(){ int x,i; cin >> x; count(x); return 0; } 15.7 Fix the nested for loops to print the count from 1 to x twice, e.g. "12....x12.....x" #include <iostream> // include the header file using namespace std; int main(){...
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...