0

Just so we've got a clearer picture, please could you post the code you're trying to compile, using Tags

Thanks

0
int main() {
       //char r,R,E,e,c,C,n,N,choice; <- Why are you setting the inputs as     
                                                       varibles? :S
       char choice[100];
       string name,movie,movietype;
       double rent, days;
       const double re=40, ch=30, nr=100, eng=40;
       cout<<"Enter Name:";
       cin>>name;
       cout<<"[R]Regular Movie\n";
       cout<<"[C]Children Movie\n";
       cout<<"[E]English Movie\n";
       cout<<"[N]New Released Movie\n";
       cout<<"Choose One:";
       cin>>choice;
       cout<<"Enter Movie Name:";
       cin>>movie;
       cout<<"Number of Days:";
       cin>>days;
       
       if((choice=='R')||(choice=='r')){
                      rent=re*days;
                      movietype="Regular";
                      }
       else if((choice=='C')||(choice=='c')){
                      rent=ch*days;
                      movietype="Children Movie";
                      }         
        else if((choice=='N')||(choice=='n')){
                      rent=nr*days;
                      movietype="New Release";
                      }     
    else if((choice=='E')||(choice=='e')){
                      rent=eng*days;
                      movietype="English Movie";
                      }

        system("cls");
        
        cout<<"Customer's Name:"<<name<<endl;
        cout<<"Movie Type:"<<movietype<<endl;
        cout<<"Movie Name:"<<movie<<endl;
        cout<<"Number of Days:"<<days<<endl;
        cout<<"Your Rental Amount is:"<<rent<<endl;
        
        getch();
        return 0;
        }

Why not use a switch statement instead of using IF?

-1

Thanks for your help Mr. kiryoku. now i am getting tired. I am working on this program since 4 hours. Now i have to get fresh. I will Check this later. If you plz use SWITCH STATEMENT instead of IF STATEMENT, i think it would be better. Isnt it? Keep on thinking its also a exercise for you. My brothers, Thanks you

0

1. I don't understand why you are setting your inputs 'r', 'R', 'c', 'C' as char.
2. If you're using string, use using namespace std; if haven't already..
That is, if you know about strings, points etc..

-1

Hello brothers,
Now i have writtren whole code of this program. But when i complie it it gives some errors.

#include <iostream.h>

main()
{
      char name[100];
      char description=0;
      char movie[200];
      char movietype;
      int reg = 40;
      int child = 30;
      int eng = 50;
      int newr = 100;
      double day;
      double total;

      cout<< "\nPlease enter the name of customer: ";
      cin>> name;
      cout<< "\nMovie description: ";
      cout<< "\n";
      cout<< "\n       Enter R for regular movie";
      cout<< "\n       Enter C for children movie";
      cout<< "\n       Enter N for new released movie";
      cout<< "\n       Enter E for english movie";
      cout<< "\n";
      cout<< "\nPlease enter movie description: ";
      cin>> description;
      cout<< "\nPlease provide following information: ";
      cout<< "\n";
      cout<< "\nMovie Name: ";
      cin>> movie;
      cout<< "\nPlease enter the number of days: ";
      cin>> day;

      switch (description)
      {                  
      case 'r':
      case 'R':
                     total=reg*day;
                     movietype = "Regular";
      break;

      case 'c':
      case 'C':
                     total=child*day;
                     movietype = "Children";
      break;

      case 'n':
      case 'N':
                     total=newr*day;
                     movietype = "New Released";
      break;

      case 'e':
      case 'E':
                     total=eng*day;
                     movietype = "English";
      break;
      }

      cout<<"\nCustomer's Name:"<<name;
      cout<<"\nMovie Type:"<<movietype;
      cout<<"\nMovie Name:"<<movie;
      cout<<"\nNumber of Days:"<<day; 
      cout<<"\nYour Rental Amount is:"<<total;

}

It gives this error 4 times.
"invalid converstion from 'const char' to 'char' "

Please check this in your Dev-C++ and must help me how i can solve this problem. I am waiting for your answer. Thanks

Edited by Dani: Formatting fixed

1

This is the last help you will recieive if you do not put your code in code-tags Thank you.

#include <iostream>
#include <windows>

int main()
{
char name[100];
char description= '0';
char movie[200];
char movietype[255]; // forgot this :)
int reg = 40;
int child = 30;
int eng = 50;
int newr = 100;
double day;
double total;

cout<< "\nPlease enter the name of customer: ";
cin>> name;
cout<< "\nMovie description: ";
cout<< "\n";
cout<< "\n Enter R for regular movie";
cout<< "\n Enter C for children movie";
cout<< "\n Enter N for new released movie";
cout<< "\n Enter E for english movie";
cout<< "\n";
cout<< "\nPlease enter movie description: ";
cin>> description;
cout<< "\nPlease provide following information: ";
cout<< "\n";
cout<< "\nMovie Name: ";
cin>> movie;
cout<< "\nPlease enter the number of days: ";
cin>> day;

switch (description)
{ 
case 'r':
case 'R':
total=reg*day;
movietype = 'Regular';
break;

case 'c':
case 'C':
total=child*day;
movietype = 'Children';
break;

case 'n':
case 'N':
total=newr*day;
movietype = 'New Released';
break;

case 'e':
case 'E':
total=eng*day;
movietype = 'English';
break;

default: cout << "Your choice was unknown";
break;
}

cout<<"\nCustomer's Name:"<<name;
cout<<"\nMovie Type:"<<movietype;
cout<<"\nMovie Name:"<<movie;
cout<<"\nNumber of Days:"<<day; 
cout<<"\nYour Rental Amount is:"<<total;

}

Edited by mike_2000_17: Fixed formatting

0

#include <iostream> not iostream.h
(and using namespace std; or preferably using std::cout; using std::cin; )

main should always return an int

As it is you are trying to cram your movietype string into a char... pay close attention to your error message, what is it saying your type needs to be? Remember a string is a character array with a '\0' terminator

p.s. if you've covered it in class, you could just use a string and be done with this mess

Edited by jonsca: n/a

0

Thanks Guys. I have solved my problem and made a program. You guys really helped me. You made my conscepts clear. So i abled to write my program. Thanks brothers.

0

It's been a stressful, timely process but glad we could help you. I hope you get a decent grade for this work, if you require any more assistance, just ask. (Aslong as you follow the rules)

:)

2

This is the best thread ever. You guys are so helpful! BTW, can you help me? I am having trouble writing a new operating system that works on desktops, cell phones, watches, the internet and ATM machines. It needs multimedia and social networking, and run Windows, Mac and Linux apps side-by-side. This is what I have so far:

#include <iostream.h>
#include <windows.h> 
int main(){   
    cout << "Hello World."; 
}

My problem is the clock keeps blinking "12:00"

Thanks!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.