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?
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.
Write a program to convert the time from 24-hour notation to 12-hour notation and vice versa. Your program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore, your program must contain at least the following function: a function to convert the time from 24-hour notation to 12-hour notation, a function to convert the time from 12-hour notation to 24-hour notation, a function to display the choices, function(s) to get the input, and function(s) to display the results. (For 12-hour time notation, your program must display AM or PM.)
It is showing error because may be I was not able to put that if statement inside any function. find out the error sand complete the program with corrected code.
this runs and everything just fine, however i cant seem to figure out why the program isnt telling to user to use a valid time for hours and minutes when it's entered over the standard time limits (i.e. cant go over 23 hours and over 59 minutes)
#include <iostream> using namespace std; //functions for converting 24hr to 12hr notation //parameters use int and void as a data type
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.
I have to program something that would convert miles per hour to seconds per mile.
I'm having an issue with something that I coded. Lines 21-23 are not showing up when I compile the program. What I'm trying to do is convert seconds into minutes.
What I have so far is
#include <iostream> using namespace std; int main() { double miles_per_hour, minutes_per_hour, seconds_per_hour, seconds, minutes; cout << "Enter the miles per hour: "; cin >> miles_per_hour;
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;
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>
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)
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?
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.
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.
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;
Creating a C# program to prompt the user to choose the correct answer from a list of answer choices of a question and if the answer is wrong then try to prompt the same question again with do while loop but it is not working as it suppose to be.
class Program { static void Main(string[] args { char UserChoice = ' '; do { Console.WriteLine("What is the command keyword to exit a loop in C#?"); Console.WriteLine("a.quit"); Console.WriteLine("b.continue");
[Code] ....
But if i use int instead of char in this program and replace a, b, c and d with 1, 2, 3 and 4 then this program work fine. What is wrong in this code when using char