Error: Invalid conversion from const char* to char -fpermissive How to fix this? | Sololearn: Learn to code for FREE!

0

Error: Invalid conversion from const char* to char -fpermissive How to fix this?

https://code.sololearn.com/c6chuoNE97ic/?ref=app switch (place) { //If place == 'a' case 'a': //Juliens Wreck, Sipalay City cout <<"\nJuliens Wreck, Sipalay City\n"; cout << "Distance - 163 km\n"; place [] ={"Wreck, Sipalay City"}; break; I also tried this but it says expected token before ] if the user choose five different places... and if they choose 1 vehicle we should prompt the user to enter the day trips they want so if all of the five places it will be conflict maybe we calculate each places first one by one like example place 1 has a distance of 20 km place 2 has a distance of 163 km place 3 .... 50 km calculate each of the distance first before adding all the expenses Or maybe the code must prompt the user first for the first selection then the second choice then the third and so on I get stuck at this I don't know please solve

12/5/2021 2:42:17 AM

shlee_

35 Answers

New Answer

+3

Shlee_, As I said before, you have a big code, and I'm on a phone, it's hard to read big code in a phone. So, it's not like I don't wanna help, but seriously, I have no idea what you want this code to do. Also if possible, learn code indentation. C++ doesn't mind indentation as much or as strictly as Python, but indentation definitely helps improve code readability : )

+3

Okay, so mutiiple destination choice is allowed. But how to manage that? I mean what if a user chooses 3 destination, but only reserve for 2 days trip. Does that make sense?

+3

That's not much of an issue, we'll think of something. I'm more concerned with time management, like what to do where user choose 3 destinations but only reserve 2 day trips. I'm concerned because the calculation is based on number of days ... Or ... number of destination must match reserved days? * I'm definitely removing my comments now, too many ...

+2

😳☺️ in C++ switch is used only with integer values. I was surprised that you have written more than 200 lines of code and have never tested it for performance.

+2

<place> is defined as `char` at line 10 char place = 'a'; But you try to assign constant char* (constant C-string) for variable <place> on the following lines 51, 60, 68, 76, 84, 92, 100, 108, 115 and 123 A `char` variable can only store 1 byte (character), the constant C-string you are trying to assign consists of multiple bytes (characters). They are two different data types, and they are not compatible one and other.

+2

Oh I see ... so they are kinda obliged to use the transportation service cause that's where most of the expenses are, right? Fine, but still, what about that 5 out of 10 places, still don't get it. I think I should comment in your code when I have questions. I feel like I'm trashing this thread. Maybe I'll remove my comments here later ...

+2

Ipang I'm thinking what if we calculate first all the distance from each places and each rental fee, fuel cost for example User choose 1 for places then 1 for vehicle then calculate all the expenses then prompt the user again to choose 1 place then 1 vehicle the proceed until it has chosen 5 outputs and add all the total expenses would it be possible ?

+2

Can you show me the code that you revised?

+1

Maybe your best bet is to contact the author of this code, Ashlie?

+1

Thats my real name Vasiliy

+1

If you want to create a switch with character values, then you need to use enum. Example: enum EnumChar { A = 'a', B, C }; char c; cin >> c; switch(c){ case A: cout << A; break; case B: cout << B; break; case C: cout << C; break; default: cout << "??"; }

+1

Ipang yeah the code must ask them if how many day trips If they will not want to rent a car then they have no payment for rental and expenses if the user will not deposit for the rental fee then the code must not allow the user to rent a car return trip = 25 km* 2 = 50 km x day trips = total distance driver fee = day trip * 1500 Fuel cost = Fuel consumption * distance travelled * fuel cost per Liter fuel cost per Liter = 60 pesos this is the same for all vehicles total payment = DEPOSIT (10,000 ) - (Rental fee + driver fee + fuel cost)

+1

Ipang No they don't need to deposit if they want to use their own vehicle user need to deposit only if they want to rent a car

+1

Oki ,... The thing is the user must select only 5 places out of ten and 1 vehicle then calculate the expenses Ipang

+1

Now you make me confused. What do you mean 5 out of 10 places? I thought user was to choose one ... Which costs are included in the calculation when they want to use their own car? surely the fuel cost, driver rate are excluded ...

+1

That's why I make switch case and for loop at first if they want their own car there's no cost or payment Ipang

+1

The user can only select <= 5 specific place but not more than

+1

Ipang There are 10 diff places right in my code I write case with char for specific place a b c d e f g h I j So the user might input only 5 places to chose and not exceed on that example : places selected: a, b, j, h g it should not exceed to five

+1

Ipang Yeah that's what I'm thinking too and I'm asking here because I don't know how to calculate if multiple destinations are allowed it does make sense ... my problem is on how to calculate the multiple destination

+1

Shlee, I see you posted a new thread, let's see what others has to say. I'm also stuck at calculation, related with the multiple destinations and number of trip days ...