Question

In: Computer Science

USE C++ and please keep program as simple as possible and also comment so it is...

USE C++ and please keep program as simple as possible and also comment so it is easy to understad

Create a structure called time. Its three members, all type int, should be called hours,
minutes, and seconds. Write a program that prompts the user to enter a time value in hours,
minutes, and seconds. This should be in 12:59:59 format. This entire input should be assigned
first to a string variable. Then the string should be tokenized thereby assigning the 1st token
to hours, 2nd token to minutes, and 3rd token to seconds member variables of the structure
called time. Finally inside a void Print_in_Seconds(void) member function of time structure,
it should print out the total number of seconds represented by this time value:
long totalsecs = t1.hours*3600 + t1.minutes*60 + t1.seconds

Solutions

Expert Solution

#include<iostream>
 
struct time   //specify the structure
    { 
    int seconds;   //three types are declared in int
    int minutes;
    int hours; 
     };

    void total_secs(struct time t1,struct time*totalsecs ); 

using namespace std;
 
int main()
{     
    struct time t1;    //total_secs and others probably aren't of type TIME, are they
    cout<<" Your Entered Time is: \n";
    cout<<"Enter the  Hours, Minutes and Seconds : "; 
    cin>>t1.hours>>t1.minutes>>t1.seconds;
    cout<<t1.hours<<":"<<t1.minutes<<":"<<t1.seconds<<endl;

    long total_secs = t1.hours*3600 + t1.minutes*60 + t1.seconds;  //Time value

    cout<<"Total number of seconds is :"<<total_secs<<endl;  //Printing Total number of seconds
 
    return 0;
}

OUTPUT:-


Related Solutions

USE C++ for the program and kindly keep it as simple as possible , use recursion...
USE C++ for the program and kindly keep it as simple as possible , use recursion and do not use loops please keep program simple and comment if possible Suppose you have been given the task to design a text editor which will take any multiline text from user and then display the statistics like total number of characters i.e., characters_count (excluding the white space and punctuations), words_count, and redundant_words_count. Create a structure named Text_Editor having four type members namely...
C++ program, I'm a beginner so please make sure keep it simple Write a program to...
C++ program, I'm a beginner so please make sure keep it simple Write a program to read the input file, shown below and write out the output file shown below. Use only string objects and string functions to process the data. Do not use c-string functions or stringstream (or istringstream or ostringstream) class objects for your solution. Input File.txt: Cincinnati 27, Buffalo 24 Detroit 31, Cleveland 17 Kansas City 24, Oakland 7 Carolina 35, Minnesota 10 Pittsburgh 19, NY Jets...
PROGRAM LANGUAGE IN C, PLEASE KEEP IT SIMPLE EVEN IF IT IS REDUNDANT In this problem...
PROGRAM LANGUAGE IN C, PLEASE KEEP IT SIMPLE EVEN IF IT IS REDUNDANT In this problem you will take a list of names from the user and sort them alphabetically using selection sort. The code for selection sort for integer is available in the "Lab and Weekly Coding Solution module" in webcourses. Ask the user how many names the user wants to input. Let's say the number be N. Then take N number of names and put them in an...
PROGRAM LANGUAGE IN C NOT C# or C++ KEEP IT SIMPLE EVEN IF IT IS REDUNDANT...
PROGRAM LANGUAGE IN C NOT C# or C++ KEEP IT SIMPLE EVEN IF IT IS REDUNDANT PLEASE. Problem: Driving Function driving(): Write a function driving(), that updates the odometer and fuel gauge of a car. The function will take in a reference to the variables storing the odometer and fuel gauge readings, along with a double representing the miles per gallon (mpg) the car gets and the number of miles the driver intends to go. The function should update the...
C++ Please. Break it down barney style if possible. Instructions Create a program to keep track...
C++ Please. Break it down barney style if possible. Instructions Create a program to keep track of the statistics for a kid’s soccer team. The program will have a structure that defines what data the program will collect for each of the players. The structure will keep the following data: Players Name (string) Players Jersey Number (integer) Points scored by Player (integer) The program will have an array of 12 players (use less for testing and development, use a constant...
Create JAVA PROGRAM, and write comment for codes also. 3) You want to keep track of...
Create JAVA PROGRAM, and write comment for codes also. 3) You want to keep track of your progress towards running a 10K. There are two kinds of races - 5K and 10K. The program needs to ask what race was run and what the time was in seconds until the user quits. When they quit, display the average and best time for each type of race in minutes.
**** Using C Sharp **** ***If possible please include screenshot of output *** **Also, if possible,...
**** Using C Sharp **** ***If possible please include screenshot of output *** **Also, if possible, please provide info from .txt files created** You are to write a program which is going to use inheritance. It should start off with the base classes Account: contains the string name, int accountnumber, double balance. Savings: Derived from Account class, it should contain double interest rate. Checkings: Derived from Account class, it should contain double overdraftlimit. CreditCard: Derived from Checkings class, it should...
20.1: Checking on the Drought [(JAVA, ECLIPSE), Please keep the program as short as possible] The...
20.1: Checking on the Drought [(JAVA, ECLIPSE), Please keep the program as short as possible] The California drought is a topic that is weighing heavily on the minds of many people in this state. With all the rain we have gotten this year, we are all hoping the drought is over Let's examine some rainfall data for Silicon Valley to get a sense of how this year's rainfall compares to the average rainfall. For this assignment, you will be practicing...
(C++) keep things as simple as possible. I would love a good starting point with hints...
(C++) keep things as simple as possible. I would love a good starting point with hints to be able to finish it! Write a function called is valid phone number that takes a phone number as an array of characters and its size, and returns true if the input array is a valid phone number, false otherwise. A phone number is valid only if it is of the following format: (uuu) uuu-uuuu where u is from ‘0’, ‘1’, ‘2’, etc....
Also please add comments on the code and complete in C and also please use your...
Also please add comments on the code and complete in C and also please use your last name as key. The primary objective of this project is to increase your understanding of the fundamental implementation of Vigenere Cipher based program to encrypt any given message based on the Vignere algorithm. Your last name must be used as the cipher key. You also have to skip the space between the words, while replicating the key to cover the entire message. Test...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT