double purchases_input (void) { double purchases = 0.0; printf ("Total Purchase Price? "); purchases = double_input (); return purchases; }
product* product_input() { product* work_product = NULL; char* name = (char*)calloc(NAM_LEN + 1, sizeof(char)); double price = 0; int number = 0; int errors = 0; printf("Input the name of the product" "(space, slash and backslash are forbidden):\n"); do { string_input(stdin, NAM_LEN + 1, name, 0); if((errors = (strpbrk(name, ESCAPE_SEQ) != NULL))) printf("\tTry again, incorrect symbols\n"); }while(errors); printf("Input the price of the single product:\n"); price = double_input(0, 9999); printf("Input the number of this product:\n"); number = integer_input(0, 999); work_product = product_create(name, price, number); return work_product; }
bool HeeksCADapp::InputDouble(const wxChar* prompt, const wxChar* value_name, double &value) { if(m_input_uses_modal_dialog) { HDialog dlg(m_frame); wxBoxSizer *sizerMain = new wxBoxSizer(wxVERTICAL); wxStaticText *static_label = new wxStaticText(&dlg, wxID_ANY, prompt); sizerMain->Add( static_label, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, dlg.control_border ); CDoubleCtrl* value_control = new CDoubleCtrl(&dlg); dlg.AddLabelAndControl(sizerMain, value_name, value_control); sizerMain->Add( dlg.MakeOkAndCancel(wxHORIZONTAL), 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, dlg.control_border ); dlg.SetSizer( sizerMain ); sizerMain->SetSizeHints(&dlg); sizerMain->Fit(&dlg); value_control->SetFocus(); if(dlg.ShowModal() == wxID_OK) { value = value_control->GetValue(); return true; } return false; } else { CInputMode* save_mode = input_mode_object; CDoubleInput double_input(prompt, value_name, value); SetInputMode(&double_input); OnRun(); SetInputMode(save_mode); if(CDoubleInput::m_success)value = double_input.m_value; return CDoubleInput::m_success; } }