I didn't look at the code, but:
while (1)
{
code here
string choice;
cout << "Would you like to play again?" << endl;
cin >> choice;
if ((choice!="y")||(choice!="yes"))
{
break;
}
}
return 0;
hope that helps,
You can also just re-execute the command with a shell execute, or something 
similar. create a process and run the second program like that, though that's 
making things harder than they should be.
Thanks,
~~TheCreator~~
Visit TDS for quality software and website production
http://tysdomain.com
visit the piratecafe for programming related resources:
http://piratecafe.net
msn: [EMAIL PROTECTED]
skype: st8amnd127
  ----- Original Message ----- 
  From: bo 
  To: [email protected] 
  Sent: Wednesday, June 11, 2008 8:36 PM
  Subject: [c-prog] restarting program from within.


  Now that I have my program working. How do I restart it from within 
  the program. I tried to do it with a do-while statement around the 
  whole program. I also added a char variable for yes or no. I hate to 
  be a bother but would you look over the code and see what I did 
  wrong. I hope one of these days I will be able to give back more that 
  I ask for help. 
  I can't even get it to start when I insert the do while. 
  Here is the code.
  /*original version Merle Hall CSS561 week 5 individual assignment*/
  /*Change request for tax calculation program at Kudler Stores*/
  /*June 7, 2008*/
  /* ver 2 removed extra semi-colons*/
  /* ver 3 added braces in function */
  /* ver 4 added conversion specifier*/
  /* ver 5 reworked formula for total*/
  /* ver 6 added input statement for amount*/
  /* ver 7 added if then for verificaton of amount*/
  /* ver 7.5 resolve typo issue on printf*/
  /* ver 8 resoved issue with if statement changed to while loop*/
  #include <stdio.h>
  #include <math.h>
  int main()
  {
  do{

  /*setting variables for store choice*/
  char cAgain;
  int iResponse;
  float fSales;
  float fTax1;
  float fTax2;
  float fTax3;
  float fTotal1;
  float fTotal2;
  float fTotal3;

  /*initializing variables*/
  cAgain = '\0';
  iResponse = 0;
  fSales = 0;
  fTax1 = .0725;
  fTax2 = .075;
  fTax3 = .0775;
  fTotal1 = 0;
  fTotal2 = 0;
  fTotal3 = 0;

  /*switch for selecting store location*/
  printf ("\n\tStore Location");
  printf ("\n1\t Del Mar\n");
  printf ("\n2\t Encinitas\n");
  printf ("\n3\t La Jolla\n");
  printf ("\n Enter the number of your store location: ");
  scanf ("%d", &iResponse );


  /*function for inputing sales*/

  printf ("\nEnter amount of purchase:\n");
  scanf ("%f", &fSales);

  /*formulas for figuring totals*/

  fTotal1 = (fTax1 * fSales) + fSales;
  fTotal2 = (fTax2 * fSales) + fSales;
  fTotal3 = (fTax3 * fSales) + fSales;

  /*while loop for input*/

  while (fSales <= 0.00) 
  {
  printf ("\n Please enter a valid amount");
  scanf ("%f", &fSales);
  }
  /* functions for printing output*/

  {
  printf ("\nThe amount you entered was: %.2f\n", fSales);
  }
  if (iResponse ==1){
  printf ("\nYour tax rate at the Del Mar store is %.4f", fTax1); 
  printf ("\nYour tax on your purchase amount at the Del Mar store 
  is %.2f", fTax1 * fSales);
  printf ("\nYour total at the Del Mar store is %.2f\n", fTotal1);
  }
  if (iResponse ==2){
  printf ("\nYour tax rate at the Encinitas store is %.4f", fTax2);
  printf ("\nYour tax on your purchase amount at the Encinitas store 
  is %.2f", fTax2 * fSales);
  printf ("\nYour total at the Encinitas store is: %.2f\n", fTotal2);
  }
  if (iResponse ==3){
  printf ("\nYour tax rate at the La Jolla store is %.4f", fTax3);
  printf ("\nYour tax on your purchase amount at the La Jolla store 
  is %.2f", fTax3 * fSales);
  printf ("\nYour total at the La Jolla store is %.2f", fTotal3);
  }

  printf ("\nIf you want to continue type y for yes or Q for quit");
  scanf ("%c", &cAgain);
  }while (cAgain == y)

  }






   

  __________ NOD32 3179 (20080611) Information __________

  This message was checked by NOD32 antivirus system.
  http://www.eset.com


[Non-text portions of this message have been removed]

Reply via email to