예제 #1
0
int Listfiles::get_hoursremaning(){
	unsigned long long hours = 0;
	if (get_hours()==0)return 0;
	hours =(unsigned long long)get_hours()*60+(unsigned long long)get_minutes();
	Serial.println((long)hours);
	hours = hours-hours*card.getSdPosition()/card.getFileSize();
	Serial.println((long)hours);
	hours = hours/60;
	Serial.println((long)hours);
	return (int) hours;
}
예제 #2
0
int Listfiles::get_minutesremanig(){
	unsigned long long minu = 0;
	if (get_minutes()==-1)return 0;
	minu = (unsigned long long)get_hours()*60+(unsigned long long)get_minutes();
	minu = minu-minu*card.getSdPosition()/card.getFileSize();
	minu = minu%60;
	return (int) minu;
}
예제 #3
0
int main(void)
{
	double basepay;
	double hours;
  double gross;
  double net;
  double taxes;
	
	int num;

	
	while(num = menu() != QUIT )
	{
		switch (num)
		{
			case 1: basepay = 8.75;
				break;
			case 2: basepay = 9.33;
				break;
			case 3: basepay = 10.00;
				break;			
			case 4: basepay = 11.20;
				break;			
			default:
				break;
		}
		printf("you have select $%.2f/hr\n",basepay);
		
		hours = get_hours();
			
		if(hours <= BASEHOURS)
					gross = basepay * hours;
		else 
					gross = basepay * BASEHOURS + (hours - BASEHOURS)*basepay*OVERTIME;
		if(gross <= LIMITE1)
					taxes = gross * RATE1;
		else if(gross<= LIMITE1 + LIMITE2)
					taxes = LIMITE1 * RATE1 + (gross - LIMITE1)*RATE2;
	  else 
	  			taxes = LIMITE1 * RATE1 + LIMITE2 * RATE2 + (gross - LIMITE1 - LIMITE2) * RATE3;
		
		net = gross - taxes;
		
		printf("%.2f hours you can earn : \n gross: %.2f \n net: %.2f \n taxes: %.2f \n",hours,gross,net,taxes);		


	}
			
return 0;
}
예제 #4
0
 int main()
 {
            
        assert(fabs(seconds_difference(1800.0, 3600.0) - 1800.0) < DBL_EPSILON); 
        assert(fabs(seconds_difference(3600.0, 1800.0) - -1800.0) < DBL_EPSILON );
        assert(fabs(seconds_difference(1800.0, 2160.0) - 360.0) < DBL_EPSILON);
        assert(fabs(seconds_difference(1800.0, 1800.0) -  0.00) < DBL_EPSILON);

        assert(fabs(hours_difference(1800.0, 3600.0) - 0.5) < DBL_EPSILON); 
        assert(fabs(hours_difference(3600.0, 1800.0) - -0.5) < DBL_EPSILON);
        assert(fabs(hours_difference(1800.0, 2160.0) -  0.1) < DBL_EPSILON);
        assert(fabs(hours_difference(1800.0, 1800.0) -  0.0) < DBL_EPSILON);

        assert(fabs(to_float_hours(0, 15, 0) - 0.25) < DBL_EPSILON);
        assert(fabs(to_float_hours(2, 45, 9) - 2.7525) < DBL_EPSILON);
        assert(fabs(to_float_hours(1, 0, 36) - 1.01) < DBL_EPSILON);
        
        assert(fabs(to_24_hour_clock(24) - 0) < DBL_EPSILON);
        assert(fabs(to_24_hour_clock(48) - 0) < DBL_EPSILON);
        assert(fabs(to_24_hour_clock(25) - 1) < DBL_EPSILON);
        assert(fabs(to_24_hour_clock(4) - 4) < DBL_EPSILON);
        assert(fabs(to_24_hour_clock(28.5) - 4.5) < DBL_EPSILON);
        
        assert(fabs(get_hours(3800) - 1) < DBL_EPSILON);
        assert(fabs(get_minutes(3800) - 3) < DBL_EPSILON);
        assert(fabs(get_seconds(3800) - 20) < DBL_EPSILON);

        assert(fabs(time_to_utc(+0, 12.0) - 12.0) < DBL_EPSILON);
        assert(fabs(time_to_utc(+1, 12.0) - 11.0) < DBL_EPSILON);
        assert(fabs(time_to_utc(-1, 12.0) - 13.0) < DBL_EPSILON);
        assert(fabs(time_to_utc(-11, 18.0) - 5.0) < DBL_EPSILON);
        assert(fabs(time_to_utc(-1, 0.0) - 1.0) < DBL_EPSILON);
        assert(fabs(time_to_utc(-1, 23.0) - 0.0) < DBL_EPSILON);

        assert(fabs(time_from_utc(+0, 12.0) - 12.0) < DBL_EPSILON);
        assert(fabs(time_from_utc(+1, 12.0) - 13.0) < DBL_EPSILON);
        assert(fabs(time_from_utc(-1, 12.0) - 11.0) < DBL_EPSILON);
        assert(fabs(time_from_utc(+6, 6.0) - 12.0) < DBL_EPSILON);
        assert(fabs(time_from_utc(-7, 6.0) - 23.0) < DBL_EPSILON);
        assert(fabs(time_from_utc(-1, 0.0) - 23.0) < DBL_EPSILON);
        assert(fabs(time_from_utc(-1, 23.0) - 22.0) < DBL_EPSILON);
        assert(fabs(time_from_utc(+1, 23.0) - 0.0) < DBL_EPSILON);

        return 0;
 }
예제 #5
0
/** 
 * Update the ticking label in hh:mm:ss format. 
 */
static void update_ticker_label (glong current_diff_seconds) {

    /**
     * Crude check to see if the preferences page is active
     * FIXME: Nicer way to check if the widgets are available rather
     * than a global boolean?
     */

    gchar *str = g_strdup_printf ("%02d:%02d:%02d", 
            (guint) get_hours(current_diff_seconds),
            (guint) get_minutes(current_diff_seconds),
            (guint) get_seconds(current_diff_seconds));
    
    if (prefs_active)
        gtk_label_set_text (GTK_LABEL (countdown), (gchar *) str); 
    if(si_alarm)
        gtk_widget_set_tooltip_text(si_alarm, str);
    g_free(str);
}
예제 #6
0
int main() {
	assert((seconds_difference(1800.0, 3600.0) - 1800.0 < DBL_EPSILON) && "test-1");
	assert((seconds_difference(3600.0, 1800.0) -( -1800.0) < DBL_EPSILON) && "test-2");
	assert((seconds_difference(1800.0, 2160.0) - 360.0 < DBL_EPSILON) && "test-3");
	assert((seconds_difference(1800.0, 1800.0) < DBL_EPSILON) && "test-4");

	assert((hours_difference(1800.0, 3600.0) - 0.5 < DBL_EPSILON) && "test-5");
	assert((hours_difference(3600.0, 1800.0) -(-0.5) < DBL_EPSILON) && "test-6");
	assert((hours_difference(1800.0, 2160.0) - 0.1 < DBL_EPSILON) && "test-7");
	assert((hours_difference(1800.0, 1800.0) < DBL_EPSILON) && "test-8");

	assert((to_float_hours(0, 15, 0) - 0.25 < DBL_EPSILON) && "test-9");
	assert((to_float_hours(2, 45, 9) - 2.7525 < DBL_EPSILON) && "test-10");
	assert((to_float_hours(1, 0, 36) - 1.01 < DBL_EPSILON) && "test-11");

	assert((to_24_hour_clock(24) < DBL_EPSILON) && "test-12");
	assert((to_24_hour_clock(48) < DBL_EPSILON) && "test-13");
	assert((to_24_hour_clock(25) - 1 < DBL_EPSILON) && "test-14");
	assert((to_24_hour_clock(4) - 4 < DBL_EPSILON) && "test-15");
	assert((to_24_hour_clock(28.5) - 4.5 < DBL_EPSILON) && "test-16");

	assert((get_hours(3800) == 1) && "test-17");
	assert((get_minutes(3800) == 3) && "test-18");
	assert((get_seconds(3800) == 20) && "test-19");

	assert((time_to_utc(0, 12.0) - 12.0 < DBL_EPSILON) && "test-20");
	assert((time_to_utc(1, 12.0) - 11.0 < DBL_EPSILON) && "test-21");
	assert((time_to_utc(-1, 12.0) - 13.0 < DBL_EPSILON) && "test-22");
	assert((time_to_utc(-11, 18.0) - 5.0 < DBL_EPSILON) && "test-23");
	assert((time_to_utc(-1, 0.0) - 1.0 < DBL_EPSILON) && "test-24");
	assert((time_to_utc(-1, 23.0) - 0.0 < DBL_EPSILON) && "test-25");

	assert((time_from_utc(0, 12.0) - 12.0 < DBL_EPSILON) && "test-26");
	assert((time_from_utc(1, 12.0) - 13.0 < DBL_EPSILON) && "test-27");
	assert((time_from_utc(-1, 12.0) - 11.0 < DBL_EPSILON) && "test-28");
	assert((time_from_utc(6, 6.0) - 12.0 < DBL_EPSILON) && "test-29");
	assert((time_from_utc(-7, 6.0) - 23.0 < DBL_EPSILON) && "test-30");
	assert((time_from_utc(-1, 0.0) - 23.0 < DBL_EPSILON) && "test-31");
	assert((time_from_utc(-1, 23.0) - 22.0 < DBL_EPSILON) && "test-32");
	assert((time_from_utc(1, 23.0) < DBL_EPSILON) && "test-33");
}
int main (void)
{
    // Initialize an array of structures with the employee number and wage rate
    struct employee employees[NUM_EMPLOYEES] =
    {
        {"Connie Cobol", 98401, 10.60}, {"Mary Apl", 526488, 9.75}, {"Frank Fortran", 765349, 10.50},
        {"Jeff Ada", 34645, 12.25}, {"Anton Pascal", 127615, 10.00}
    };
    
    // Function declarations
    void get_hours (struct employee employees[], int size);
    void calculate_gross_pay (struct employee employees[], int size);
    void calculate_overtime (struct employee employees[], int size);
    void print_employee_wages (struct employee employees[], int size);
    
    //-*-*-*-*-Begin creating the nuts and bolts-*-*-*-*-
    get_hours(employees, NUM_EMPLOYEES);
    calculate_overtime(employees, NUM_EMPLOYEES);
    calculate_gross_pay(employees, NUM_EMPLOYEES);
    print_employee_wages(employees, NUM_EMPLOYEES);
}
//---------------------------------------------------------------------------------------
//Output Date (dd-mm-yy) & Time (hh:mm:ss)
int output_date_time(void){
	// Get the current date and time
	ds1307_read_date_time();
	// Get binary values + convert to ascii string
	bin_to_ascii(get_seconds(), secondASCII);
	bin_to_ascii(get_minutes(), minuteASCII);
	bin_to_ascii(get_hours(), hourASCII);
	bin_to_ascii(get_day(), dayASCII);
	bin_to_ascii(get_month(), monthASCII);
	bin_to_ascii(get_year(), yearASCII);
	// Send to LCD
	lcd_send_cmd(LINE1);
	lcd_printf(hourASCII); lcd_printf(":");
	lcd_printf(minuteASCII); lcd_printf(":");
	lcd_printf(secondASCII);
	lcd_send_cmd(LINE2);
	lcd_printf(dayASCII); lcd_printf("-");
	lcd_printf(monthASCII); lcd_printf("-");
	lcd_printf(yearASCII);
		
	return 0;
}
예제 #9
0
void mc146818_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	switch (id)
	{
	case TIMER_PERIODIC:
		m_data[REG_C] |= REG_C_PF;
		update_irq();
		break;

	case TIMER_CLOCK:
		if (!(m_data[REG_B] & REG_B_SET))
		{
			/// TODO: find out how the real chip deals with updates when binary/bcd values are already outside the normal range
			int seconds = get_seconds() + 1;
			if (seconds < 60)
			{
				set_seconds(seconds);
			}
			else
			{
				set_seconds(0);

				int minutes = get_minutes() + 1;
				if (minutes < 60)
				{
					set_minutes(minutes);
				}
				else
				{
					set_minutes(0);

					int hours = get_hours() + 1;
					if (hours < 24)
					{
						set_hours(hours);
					}
					else
					{
						set_hours(0);

						int dayofweek = get_dayofweek() + 1;
						if (dayofweek <= 7)
						{
							set_dayofweek(dayofweek);
						}
						else
						{
							set_dayofweek(1);
						}

						int dayofmonth = get_dayofmonth() + 1;
						if (dayofmonth <= gregorian_days_in_month(get_month(), get_year() + 2000))
						{
							set_dayofmonth(dayofmonth);
						}
						else
						{
							set_dayofmonth(1);

							int month = get_month() + 1;
							if (month <= 12)
							{
								set_month(month);
							}
							else
							{
								set_month(1);

								set_year((get_year() + 1) % 100);
							}
						}
					}
				}
			}

			if ((m_data[REG_ALARM_SECONDS] == m_data[REG_SECONDS] || (m_data[REG_ALARM_SECONDS] & ALARM_DONTCARE) == ALARM_DONTCARE) &&
				(m_data[REG_ALARM_MINUTES] == m_data[REG_MINUTES] || (m_data[REG_ALARM_MINUTES] & ALARM_DONTCARE) == ALARM_DONTCARE) &&
				(m_data[REG_ALARM_HOURS] == m_data[REG_HOURS] || (m_data[REG_ALARM_HOURS] & ALARM_DONTCARE) == ALARM_DONTCARE))
			{
				// set the alarm interrupt flag AF
				m_data[REG_C] |= REG_C_AF;
			}

			// set the update-ended interrupt Flag UF
			m_data[REG_C] |=  REG_C_UF;
			update_irq();

			m_last_refresh = machine().time();
		}
		break;
	}
}
예제 #10
0
MicroTime::MicroTime(qint64 time)
        :QTime(get_hours(time) % 60, get_minutes(time) % 60, get_seconds(time) % 60 )
{}
int main()
{
	assert(get_hours(3800) == 1);
}