C/C++ :: Converting Minutes To Hours
Oct 23, 2014
I am currently working on a lab for my intro to programming class and the lab is asking for a long distance call calculator. Based on the times that you start your rate will change. If the call starts from 00:00 to 07:59, Rate = $0.07. If the call starts from 08:00 to 18.59, Rate = $0.12. Lastly if the call starts from 19:00 to 23:59, your rate is $0.28.
Then on the output you must show the start time, end time, rate, and total cost of the call.
My confusion is on the end part of the code (the output).
I know you have to use the % operator to convert minutes to hours, but I don't completely understand it which is why I am here. How does the modulus do that? And how will it go over to the next hour if the call starts at 1:35 and ends after 30 minutes (2:05)?
Here is what I have so far.
#include <iostream>
#include <string>
using namespace std;
int main() {
float callStart, minutes;
double cost;
char choice('Y');
string rate;
[Code] ....
View 5 Replies
ADVERTISEMENT
Jul 24, 2014
The problem is that I need to figure out the user's birthday in months, days, hours, and minutes from today's date.
Here's what I have so far.
#include<iostream>
#include<cmath>
#include<ctime>
using namespace std;
int main() {
int todayDay, todayMonth, todayYear;
int birthDay, birthMonth, birthYear;
[Code] ....
I haven't initialized all the variables, yet. And it's very unfinished. I need to figure out how to convert years from the age into months only. And I need to figure out how to calculate the hours, seconds, and minutes.
View 3 Replies
View Related
Jul 10, 2013
I want to convert seconds into hours, min and seconds. I was able to test it with a small equation turning seconds into hours but now it returns zeros for every entry.
Code:
#include <stdio.h>
void secCount(int *seconds, int *hours, int *min, int *sec);
int main(int argc, const char * argv[]) {
int sec=0, hours=0, min=0, seconds =0;
[Code] .....
View 5 Replies
View Related
Apr 19, 2014
I am reading up on the clock() function: URL....It states: "On a 32bit system where CLOCKS_PER_SEC equals 1000000 this function will return the same value approximately every 72 minutes."
How could this return the same value, if clock is the number of clock ticks elapsed since program execution. Wouldn't the number of clock ticks continue to grow, and as such, when we divide by 1000000, the return value should continue to grow. So how does this function return same value every 72 minutes?
View 2 Replies
View Related
Sep 1, 2014
I have a function which sometime takes more than 24 hours to run. So I want a code which will check the time and exit the function if the function executin is not successful and return to main function.
View 9 Replies
View Related
Dec 18, 2014
Understanding Fork() calls. I have to write a C program in UNIX machine, and make two Fork Calls Inside it and have these two instances run every five minutes all round the clock. How to achieve this.
View 1 Replies
View Related
Apr 7, 2014
I want to add a count down timer to my testing software 1hr and 30min
Its a 32bit console application, I want the countdown timer outputted above each question on the right side, timer only needs to output the time left at the top of each question so a live outputted timer is not important.
Questions are not random generated.
Also how to output "out of time" if the timer reaches 0 and for the test to end, I think branching is involved not too sure.
I already have, std::srand( std::time(0) ) ; at the start of the test to randomly generate the answer order.
View 10 Replies
View Related
Nov 2, 2013
In an assignment where they were asked to write a simple alarm that went off every 12 hours. This seemed mildly interesting so I gave it a go. The alarm actually goes off every minute (to have it go off every hour, or every 12, or some other interval more cogs, shafts and pinions would need to be added to the mechanism).
Code:
/* A simple "stopwatch" that prints an alarm message every minute.
*
* 2-Nov-2013
*
*/
#include <stdio.h>
#include <stdbool.h>
#include <time.h>
[Code] .....
View 8 Replies
View Related
Oct 6, 2013
I'm writing a program that converts seconds to hours and minutes - That works fine! But if I write: 3700 seconds It answers That equals to: 1 hours, 1 minutes and 40 seconds.
I now want my program to write 1 hour, 1 minute and 40 seconds.
And if there is no hours at all it should only write 400 seconds equals 6 minutes and 40 seconds.
To sum up: The program shall write hour/hours minute/minutes second/seconds correct.
I've made one succesfull program, but it was written with 27 "if-statements" and I know there is a better way.
Code:
#include <stdio.h>
int
main(void) {
[Code]...
how to make the program know when to write hour or hours?
View 10 Replies
View Related
Mar 13, 2013
I am looking for a function or any example that shows elapsed time in seconds and minutes. I didn't find any solution for both OS Win and Linux. I am looking for example that works for both - win and linux.
View 14 Replies
View Related
Oct 1, 2013
Write your question here.
Here is the code
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
using std::fixed;
#include <iomanip>
[Code] ....
My question is how would i put in the total of hours for the vehicles and the total hours for the garage for the vehicles of input... set like this
Car Hours Charge
1 1.5 2.00
2 4.0 2.50
3 24.0 10.00
Total 29.5 14.50 <---This is what i need for my code still
View 1 Replies
View Related
Sep 20, 2014
The question is to write a program to add two time objects.
Here's what I did:
#include<iostream.h>
#include<conio.h>
class Time {
public:
int hours,minutes,seconds;
[Code] .....
There's an error in sum of hours in the output.
View 5 Replies
View Related
Oct 22, 2013
I have to write a program for class in which users will be inputting:
start time = startTime
number of minutes = callDuration
so first off, teacher wants us to input time as a floating point number such as 09.00
How do I validate the time so that users cant input i.e. 09.61 for every hour? In other words, so the user cant input minutes 60-99 for every hour.
then, when calculating:
endTime = startTime + callDuration
how would I make endTime display a correct time in such a situation: endTime = 09.45 + 00.30
so that it displays 10.15 not 09.75
View 4 Replies
View Related
Nov 29, 2014
Design, implement, and test a class that represents an amount of time in minutes and seconds. The class should provide a constructor that sets the time to a specified number of minutes and seconds. The default constructor should create an object for a time of zero minutes and zero seconds. The class should provide observers that return the minutes and the seconds separately, and an observer that returns the total time in seconds (minutes x 60 + seconds). Boolean comparison observers should be provided that test whether two times are equal, one time is greater than the other, or one time is less than the other. (You may use RelationType and function ComparedTo if you choose). A function should be provided that adds one time to another, and another function that subtracts one time from another. The class should not allow negative times (subtraction of more time than is currently stored should result in a time of 0:00). This class should be immutable.
this is one of my main errors: Error1error C2653: 'Time' : is not a class or namespace namec:userskdesktop
oane statecisp 1610visual studioschapter 12 assignmentchapter 12 assignmentchapter 12 assignment.cpp131Chapter 12 Assignment
//The implementation file ImplFileTimeClassAsgnt.cpp:
#include "Time.h"
#include <iostream>
using namespace std;
Time::Time() {
mins = 0;
secs = 0;
[Code] ....
View 2 Replies
View Related
Oct 5, 2014
Write a payroll program that prompts for the number of hours an employee worked, as well as the employee’s pay rate. If the employee worked for 40 hours or less, the gross pay is calculated by multiplying the number of hours worked by the pay rate. If the number of hours worked by the employee exceeds 40 hours, the employee should receive regular pay for the first 40 hours, and receive time-and-a-half pay for the hours in excess of 40. Display the calculated gross pay on the screen.
Continue to prompt for similar data for more employees and have the gross pay of each employee displayed, until there is no more employee data to process. Then display “Good Bye”.
Your solution must be separated into three source files (Interface, Implementation, and Test)
View 3 Replies
View Related
Sep 21, 2014
ok so i did a program that will take the number of hours worked in a week annd the number of dependents ans inputs and then outputs the workers gross pay, each withholding amount, and the net take home pay per week.
The Program should come out as this:
Regular Hours :34
Overtime hours: 0
gross pay : $323.00
social tax: 19.38
federal tax: $45.22
Statte tax: $16.15
Number of dependents covered: 2
additional health insurance expence: $0
Net take home pay: $236.25
The employer pay rate is 9.50
the employer worked 34 hours "regular hours 40 or less"
if any hours are paid at over time rate of one and one half time that from the gross pay, 6% of social is with held, 14% form federal income, 5% from state income, 6$ per week from union dues, and if worker has 3 or more covered dependent, then an additional 10$ is wothheld to cover the extra cost of health insurance
heres my program:
#include <iostream>
using namespace std;
int main () {
int regHours; // Regular Hours
float hourlyPay, gross, otime, socialtax, federaltax, statetax, uniondues, dep, health; // gross income, overtime, social tax, federal tax, state tax, union dues, depen covered, health insurance
[Code] .....
the program runs but theres still errors in it, it did not make some of the calculations right.
What formula do I use to calculate overtime hours if there was over time?
What formula do I use to take out union dues from total income?
How to I set the number of independents covered to match the health cost if it was 3 or more?
View 1 Replies
View Related
Feb 22, 2014
Create a class to store a value that represents number of hours worked and number of days worked. Must ensure that the two representations are always consistent. I have to create 2 files, I'm pretty sure: a .cpp and a .h
This is what I have so far for my .h file (I know it's NOT functional...yet):
#include <iostream>
using namespace std;
class NumDays {
private:
double hours;
double days;
[Code] ...
I don't know how to start / create this .cpp file to define the variables.
View 3 Replies
View Related
Oct 8, 2013
Write a program in C++ that calculates the amount to be paid to an employee based on the hours worked and rate per hour. A user will enter hours worked and rate per hour for an employee. Your program should have a function payCheck that calculates and returns the amount to be paid. The formula for calculating the salary amount is as follows: for the first 40 hours, the rate is the given rate (the rate that a user has entered); for hours over 40, the rate is 1.5 times the given rate.
I had write my own coding, but it keeps error. it is okay. But i still don't think i could share here? Still running... I will update my coding for you alls to check for any syntax or logic error. The problem is i need to calculate if the employee work for more than 40 hours which 1.5 times.
Code:
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <iostream.h>
using namespace std;
int main(void) {
char *empname, *test, *final_output;
[Code] .....
View 7 Replies
View Related
Feb 20, 2014
Why is this
Code: fFile << (char) (i)p.x, (char) (i)p.y,(char) (i)p.z); not the same as this
Code: printf("%c%c%c", (i)p.x, (i)p.y, (i)p.z);
View 13 Replies
View Related
Jan 3, 2013
From my tests I found the problem to be somewhere in the Mantissa part that converts it to binary.
bool xsDLL GetHexFromSF_IEEE754( void* to, Text from, ui08 tSize ) {
from.UpperCase();
int db = 0, dB = 0, dBEnd = tSize, dBLast = ( tSize - 1u ), dbEnd = dBEnd * 8;
ui08 *data = reinterpret_cast< ui08* >( to );
for ( ; dB >= 0; --dB )
data[ dB ] = 0u;
[Code] ....
Adjustments made, still having problems though. After finding a more useful resource [URL] ..... I got the function looking more like it should but am still having problems...
View 1 Replies
View Related
Apr 7, 2013
I am in a c++ class and my group is having a hard time making this work... It keeps saying that 'fileOne.open' isn't working.
#include <iostream>
#include <string>
#include <fstream>
[Code]....
View 3 Replies
View Related
Nov 8, 2014
Having trouble converting char to hex.
according to here [URL] ....
ô in decimal is 147 and print ô using alt 147
and here [URL] ....
ô in dec is 244 but prints ⌠ using alt 244
put on console
char c = ô;
cout << (int)c << endl;
prints -109 and print m using alt -109
I am using alt to test char output. Why I'm getting a negative value? Which of the tables are correct? I have string of char that I want to print in hex. I get a hex string but the hex value don't correspond to any of the two tables on the websites because the console converts special char to negative values.
View 2 Replies
View Related
May 16, 2013
I am having problems with converting a CString to an int and than doing checks on the int to see if it is in a particualr range.Below is what I am doing.
CString numstr = "28"
int num = atoi(numstr);
BOOL valid = TRUE;
if(num < -32,768 {
valid = FALSE;
}
For some reason when running the above code the if statement is executed but it should not be becasue 28 is not less than -32,768. Why this is happening, I am not seeing the reason for this at all!! The num variable is being assigned the correct value.
View 5 Replies
View Related
Jun 8, 2014
I am having trouble converting strings in my application.
This is the code that is eventually getting called, the first parameter takes a LPCWSTR
Code:
hr = m_pGraph->RenderFile(m_filePath, NULL); // takes LPCWSTR This is where the trouble begins.
The compiler shows that sResult is proper but after I try to convert a std::string to a wchar it prints garbage
Code: const wchar_t* m_filePath = (wchar_t *) oDb->GetNext().c_str();
Code:
std::string CSqlLiteDatabase::GetNext() {
sqlite3_stmt *oStmt = nullptr;
std::string sql = "SELECT path || filename FROM table WHERE id = 1";
char message[255];
[Code] ....
View 6 Replies
View Related
May 18, 2014
Code:
void convertNetPay(float netPay, char *netPayString){
int numHuns, numTens, numOnes;
char OnesTable[9][8]={"One","Two","Three","Four","Five","Six","Seven","Eight","Nine"};
char ResultString[10+1];
char TensTable[9][8] = {"Ten","Twenty","Thirty","Forty","Fifty","Sixty","Seventy","Eighty","Ninety"};
char TeensTable[9][10] {"Eleven","Twelve","Thirteen","fourteen","fifteen","Sixteen","Seventeen","Eighteen","Nineteen"};
float cents;
[Code] ....
I have to convert my netpay which is a float to a string So if I input a value of say, 356.26 it should output "the sum of three hundred fifty-six and 26/100 dollars" . My program function works for the sum of three hundred but after that it spits out garbage.
View 2 Replies
View Related
Jun 3, 2014
i m trying to write a code that would convert a each letter from a text to their decimal images . while i was able to write the part of entering the text , i cant do the converting part , i searched all day on the internet and found nothing.
View 3 Replies
View Related