hi..i had problem in my coding..can u fix for me??urgently.. -
#include<iostream>
-
#include<string>
-
using namespace std;
-
int main()
-
{
-
string movie_name;
-
int ticket_price;
-
double adult_ticket_price;
-
double child_ticket_price;
-
int child;
-
int x;
-
float tax;
-
int time;
-
int cinema_num;
-
int num_of_seat;
-
int jumlah;
-
jumlah=0;
-
cout<<"enter the movie_name";
-
cout<<endl;
-
cout<<"enter the time\n";
-
cin>>time;
-
cout<<"enter num_of_seat\n";
-
cin>>num_of_seat;
-
cout<<"enter cinema_num\n";
-
cin>>cinema_num;
-
cout<<"tax is 1.40\n";
-
cin>>tax;
-
child_ticket_price=5;
-
child=0;
-
switch (ticket_price,movie_name)
-
{
-
case '1':
-
cout<<"ghost_rider";
-
cout<<ticket_price;
-
cout<<9;
-
break;
-
case '2':
-
cout<<"meet_the_robinsons";
-
cout<<ticket_price;
-
cout<<11;
-
break;
-
case '3':
-
cout<<"death_note_III";
-
cout<<ticket_price;
-
cout<<11;
-
break;
-
case '4':
-
cout<<"hard_candy";
-
cout<<ticket_price;
-
cout<<11;
-
break;
-
case '5':
-
cout<<"spiderman_III";
-
cout<<ticket_price;
-
cout<<10;
-
break;
-
case '6':
-
cout<<"kun_fai_bin";
-
cout<<ticket_price;
-
cout<<11;
-
break;
-
case '7':
-
cout<<"lagend_of_snake";
-
cout<<ticket_price;
-
cout<<9;
-
break;
-
default:
-
cout<<"movie_name && ticket_price";
-
for(x=0;x<6;x++)
-
{
-
cout<<x;
-
jumlah=x*ticket_price;
-
cout<<jumlah;
-
cout<<"adult_ticket_price";
-
for(child=0;child<=4;child++)
-
cout<<"child_ticket_price";
-
jumlah=x*child_ticket_price;
-
cout<<jumlah;
-
-
}
-
for(x=0;x<10;x++)
-
{
-
cout<<x;
-
jumlah=x*ticket_price;
-
cout<<jumlah;
-
if(child)
-
cout<<"child_ticket_price";
-
cout<<5;
-
jumlah=x*child_ticket_price;
-
cout<<jumlah;
-
}
-
tax=1.40*jumlah;
-
cout<<tax;
-
cout<<ticket_price;
-
return 0;
-
}
-
}
-
-
blablabla\Commo n\MSDev98\Bin\b b.cpp(31) : error C2450: switch expression of type 'class std::basic_stri ng<char,struct std::char_trait s<char>,class std::allocator< char> >' is illegal
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
bb.obj - 1 error(s), 0 warning(s)
-please help me out..
1 1926 horace1 1,510
Recognized Expert Top Contributor
the control expression in a switch -
switch (ticket_price,movie_name)
must evaluate to an integral value so as ticket_price is an int this
should work
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Donald Canton |
last post by:
Hi,
I'm using Bjarne's book to learn C++ and am stuck on the Calc program
in Section 6. Everything works fine except when I try to use
istringstream to parse a token from the command line. I thought I
followed his instructions on page 118 correctly, but I can't get it to
compile without syntax errors in the get_token() function. The whole
program follows with the four syntax errors flagged with the text "//
SYNTAX ERROR". Thanks in...
|
by: learning_C++ |
last post by:
Hi,
I try to use
input = new istrstream(argv,strlen(argv));
in my code, but it always says error: " error: parse error before `('
token"
please help me!
Thanks,
#include <map>
|
by: WindAndWaves |
last post by:
Hi Gurus
The page below has a strange error. It seems to be working very well, just
when you enter 8 or 9 for day, month or year then you get an error. I
really have no idea where that is coming from. Can you help?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
|
by: Christopher Benson-Manica |
last post by:
Can you goto switch labels?
int i=0; /* arbitrary */
switch( i ) {
case 0:
if( !some_validity_check() ) {
goto error; /* could be default as well */
}
/* proceed normally */
|
by: Adam Blair |
last post by:
Is it possible to bind a switch statement to an Enum such that a compile-time
error is raised if not all values within the Enum are handled in the switch
statement? I realise you can use default: to catch unhandled cases, but of
course this is only at run-time.
Example:
public enum MyEnum
{
one, two, three, four
}
| |
by: serrand |
last post by:
Could someone tell me a beautiful way to exit from a switch and a loop in one statement ...
without using a goto... and if possible without using an auxiliary variable as i did...
int res;
while (1)
{
res = 0;
if ((i = msgrcv (msqid, &rq_resa, SZ_MsgSrcResa, pid(), 0) == -1)
{
aff_erreurs ("msgrcv", "Error when recieving message : %d", errno);
|
by: daraburke78 |
last post by:
Hi,
This is my first time using the htmlrequest and I'm having a bit of
trouble.
I have a table that looks something like this
NAME STATUS
name1 ... ETK
name2 ... Recruiter
name3 ... ETK
name4 ... Recruiter
|
by: gary0gilbert |
last post by:
An unusual spin to this recurring disk or network error in a Terminal
Server environment. Access 2000, Terminal Server 2000, file server is
windows 2000. All users have a separate copy of the front end db,
everyone accesses the back-end db via a network share. To preface,
non Terminal Server users (4 or 5 in office) never have this problem.
There are two Terminal Servers running win 2000, both basically
identical. This error affects...
|
by: jalqadir |
last post by:
In my program I have the following statements
void Person::setTitle(const Glib::ustring& str) {
switch ( str ) {
case "None" : {
title = title_t::None;
break;
}
case "Dr" : {
title = title_t::Dr;
|
by: Rohit |
last post by:
Hi,
I am working on a switch module which after reading voltage through a
port pin and caterogizing it into three ranges(open,low or high),
passes this range to a function switch_status() with parameters value
and signal ID. Signal Id is used to get a user configurable parameter
inside a configuration file, which depends on the type of switch.
I have implemented it as under. Please ignore those magic numbers as I
have mimized logic to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |