hello. i have a problem in selecting destination and time. when i select any number in destination the program always tell me that i choose number 1 (taiping). and the time it always show 1030 even i input number that is not 1. please tell me where i'm wrong here. thank you :)
#include <stdio.h>
int main ()
{
int type, desti, time, amount, time2;
char* bus[99];
char* dest[99];
double price, tprice;
printf ("------------------------------\n");
printf ("| Speed of Light Bus Company |\n");
printf ("------------------------------\n\n");
printf ("------------------------------------------------| \n");
printf (" |Please select your preferred type of bus | \n");
printf (" |1. Single-decker\t\t\t |\n");
printf (" |2. Double-decker\t\t\t |\n");
printf ("------------------------------------------------| \n\n");
printf (" >> ");
scanf ("%d", &type);
if (type = 1)
printf ("\n >> You've selected single-decker type\n\n");
else if (type = 2)
printf ("\n >> You've selected double-decker type\n\n");
else
printf ("\n >> Please enter the correct number\n");
if (type = 1)
bus[99] = "Single-decker";
else
bus[99] = "Double-decker";
printf ("-------------------------------------| \n");
printf (" |Please choose your destination| \n");
printf (" |1. Taiping >> RM28.30\t\t|\n");
printf (" |2. Pulau Pinang >> RM31.20\t|\n");
printf (" |3. Kuala Lumpur >> RM33.80\t|\n");
printf (" |4. Alor Setar >> RM36.80\t|\n");
printf (" |5. Kuantan >> RM16.30\t\t|\n");
printf (" |6. Seremban >> RM27.40\t|\n");
printf (" |7. Melaka >> RM39.50\t\t|\n");
printf (" |8. Johor Bharu >> RM32.10\t|\n");
printf ("-------------------------------------| \n\n");
printf (" >> ");
scanf ("%d", &desti);
if (desti = 1) {
printf ("\nYou've selected --> Taiping >> RM28.30\n");
dest[99] = "Taiping\0";
price = 28.30; }
else if (desti = 2) {
printf ("\nYou've selected --> Pulau Pinang >> RM31.20\n");
dest[99] = "Pulau%%Pinang\0";
price = 31.20; }
else if (desti = 3) {
printf ("\nYou've selected --> Kuala Lumpur >> RM33.80\n");
dest[99] = "Kuala%%Lumpur\0";
price = 33.80; }
else if (desti = 4) {
printf ("\nYou've selected --> Alor Setar >> RM36.80\n");
dest[99] = "Alor%%Setar\0";
price = 36.80; }
else if (desti = 5) {
printf ("\nYou've selected --> Kuantan >> RM16.30\n");
dest[99] = "Kuantan\0";
price = 16.30; }
else if (desti = 6) {
printf ("\nYou've selected --> Seremban >> RM27.40\n");
dest[99] = "Seremban\0";
price = 27.40; }
else if (desti = 7) {
printf ("\nYou've selected --> Melaka >> RM39.50\n");
dest[99] = "Melaka\0";
price = 39.50; }
else if (desti = 8) {
printf ("\nYou've selected --> Johor Bharu >> RM32.10\n");
dest[99] = "Johor%%Bharu\0";
price = 32.10; }
else
printf ("\nPlease enter the correct number : ");
printf ("\nPlease enter how many ticket you want >> ");
scanf ("%d", &amount);
tprice = price * amount;
printf ("--------------------------------------| \n");
printf (" |Please choose what time you want | \n");
printf (" |1. 1030\t\t\t |\n");
printf (" |2. 1430\t\t\t |\n");
printf (" |3. 1800\t\t\t |\n");
printf (" |4. 2230\t\t\t |\n");
printf ("--------------------------------------| \n\n");
printf (" >> ");
scanf ("%d", &time);
if (time = 1)
time2 = 1030;
else if (time = 2)
time2 = 1430;
else if (time = 3)
time2 = 1800;
else if (time = 4)
time2 = 2230;
else
printf ("\nPlease enter the correct number : ");
printf ("\nThis is your ticket information : \n");
printf ("Bus type : %s\n", bus[99]);
printf ("Destination : %s\n", dest[99]);
printf ("Total price = %0.2f \n", tprice);
printf ("Time : %d\n", time2);
}