>is there a way to input a new usewr while the program is running?
Yes, of course. Just maintain a list of valid users, and when adding a new user, append to the list. Unfortunately, without further detail about how you're going about things, I can't be more specific.
Here is some of the basic code:
/*
Name: Adam Adamowicz
Id #: 114861
Lab Section: G
Lab: 5, Program: 2.0
This program will demonstrate the basic programming needed for a fastfood resteraunt
computer program.
*/
#pragma hdrstop
#include <condefs.h>
#include <stdio.h>
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
int drinkchoice;
char mealchoice;
float mealprice, mealgst, drinkprice, drinkgst, total;
printf ("McKrusty's Main Meals:\nA. Krusty Burger\nB. Krusty Fries\nC. Krusty Buns\nEnter your choice here: ");
scanf (" %c", &mealchoice);
printf ("\nMcKrusty's Drinks: \n1. Krusty Pop \n2. Krusty Juice \nEnter your choice here: ");
scanf (" %d", &drinkchoice);
switch(mealchoice)
{
case 'A': mealprice = 4.25;
break;
case 'B': mealprice = 1.75;
break;
case 'C': mealprice = 3.50;
break;
default : mealprice = 0.0;
break;
}
switch(drinkchoice)
{
case 1: drinkprice = 1.50;
break;
case 2: drinkprice = 2.25;
break;
default : drinkprice = 0.0;
break;
}
mealgst = ( mealprice * .07);
drinkgst = ( drinkprice * .07) ;
total = mealprice + drinkprice + drinkgst + mealgst ;
printf ("\nPrice of Krusty meal: \t$%5.2f\n", mealprice);
printf ("Krusty meal GST: \t$%5.2f\n", mealgst);
printf ("Price of Krusty drink: $%5.2f\n", drinkprice);
printf ("Krusty drink GST: \t$%5.2f\n", drinkgst);
printf ("\nTotal: \t\t\t$%5.2f\n", total);
printf ("\n\nPress \"Enter\" to quit.\n");
getchar ();
getchar ();
return 0;
}
And for the change calculator
/*
Name: Adam Adamowicz
Id #: 114861
Lab Section: G
Lab: 6, Program: 1.0
This program will emulate a vending machine.
*/
#pragma hdrstop
#include <condefs.h>
#include <stdio.h>
#include <math.h>
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{ int choice;
float price, money;
printf ("Your choices are: \n 1. Chocolate Bar ($1.25)\n 2. Granola Bar ($1.50)\n 3. Crispy Square ($0.75)\nEnter your choice here: ");
scanf (" %d", &choice);
printf ("\n");
switch (choice)
{
case 1: price = 1.25; break;
case 2: price = 1.50; break;
case 3: price = 0.75; break;
default: price = 0.00; break;
}
while (price > 0)
{
printf ("Enter $%4.2f: ", price);
scanf (" %f", &money);
price -= money;
}
price = fabs(price);
printf ("\nYou get $%4.2f back in change.", price);
printf ("\n\nPress \"Enter\" to quit.");
getchar();
getchar();
return 0;
}