View Single Post
Old 03-22-2004, 01:43 PM   #1 (permalink)
Isioviel
Registered User
 
Isioviel's Avatar
 
Join Date: Mar 2004
Posts: 3
Isioviel is on a distinguished road
Unhappy C++/C conversion - Not going well

I'm new at programming in both C and C++. I have a project that I am able to compile and run in C++, and am having a bit of trouble in geting it to work for me in C. So far, my curent code is giving me quite a few errors, and when the code does run, I get an access violation. Can anyone help me with what is wrong?

Thank you in advance, for your time in answering a newbie.

Code:
/*//:: 'Virtual' cell phone written in C to calculate cell phone usage,
//:: Display cost per minute over the fake phones service plan,
//:: Displays the amount of service plan time used in Peak minutes and Off 
//::peak minutes.
//:: As more calls are made, the screen for the virtual phone will refresh 
//::to display
//:: the changes made in minutes and costs.
//:://////////////////////////////////////////////
*/

#include <stdio.h>

int main()
{
  double Fee;
  float Cost;
  int Length, Off, Peak;
  char N, O, P, Y, Ans1, Ans2;

  Cost = 0.00;
  Fee = .39;
  Length = 0;
  Off  = 0;
  Peak = 0;

  while(Ans1='Y')
{
  printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
  printf(" FFFFF  A     U   U X   X
        \r F     A A    U   U  X X
        \r FFFF A   A   U   U   X
        \r F   A A A A  U   U  X X
        \r F  A       A UUUUU X   X

        \r  FFFF OOO  NN   N EEEE
        \r  F   O   O N N  N E
        \r  FFF O   O N  N N EEEE
        \r  F   O   O N   NN E
        \r  F    OOO  N    N EEEE ");

  printf("\n\nCost: $%d  Peak: %d   Off: %d", Cost, Peak, Off);

   printf("\n\nWould you like to make a call?[Y/N] ");
   scanf("%s", Ans1);
    if(Ans1 == 'Y' || Ans1 == 'y'){
    
  printf("\nHow many minutes is the call?");
   scanf("%d", Length);

  printf("\nIs that Peak or Off minutes?[P/O]");
   scanf("%s", Ans2);
   Ans2 = toupper(Ans2);

if(Ans2 == 'P'){
   Peak = Peak + Length;
}else{
   Off = Off + Length;
}
if(Peak > 30){
  Cost += (Peak - 30) * Fee;
}
if(Off > 200){
  Cost += (Off - 200) * Fee;
}
  }
 }
}
Isioviel is offline   Reply With Quote