Need help in this question

***I have already solved Option 1 and Option 2, can anybody help me with Option 3? Thank you.
_______________________________________________________________________________


Build a “Point of Sales” C program for BIGSALES mall that fulfil the below
requirements:

1. Print a unique greeting message and logo for your point of sales program. And, prompt the user to enter the year of birth.

2. After that, the program should allow user to choose from the 4 options below:

Option 1: Enter products purchased
Option 2: Enter parking hours
Option 3: Calculate and print the total bill
Option 4: Exit

Option 1 requirements:
The program should read in an indefinite series of products (product code and quantity) purchased by customer. Same product code can be entered more than once.

Given that the retail prices of the products sold by BIGSALES mall are limited to four codes and as listed below:

Product code | Retail price (RM)
1 | 45.20
2 | 14.50
3 | 3.45
4 | 7.80


Option 2 requirements:
The program should read in the customer’s total parking hours. The hours can be in fraction (e.g. 3.15 hours).

Given the calculation of parking fee as below:

Parking fees calculation
RM2.00 minimum fee to park for up to three hours and an additional RM0.50 per hour for each hour or part thereof over three hours. The maximum charge for any given 24-hour period is RM10.00. No car parks for longer than 24 hours should be calculated.


Option 3 requirements:
Your program should calculate and display the total bill in a neat format by listing out:
• The total bill and quantity sold for each product code
• The subtotal of the bill
• The 6% government tax of the subtotal
• The total parking hours and parking fees
• The grand total. If the customer is a senior citizen (60 years old and above), he/she shall be given a 10% discount on the grand total. (Assume the current year is 2013).

Note: Your program should use a switch statement to determine the option chosen by the user. Your program should not exit if user does not choose option 4.


You are encouraged to improve your code structure by using any additional controls, validations, or messages which you think are appropriate.

You are allowed to have variances of display design, arrangement or format, as long as it fulfilled the requirement stated above.


_______________________________________________________________________________

***I have already solved Option 1 and Option 2, can anybody help me with Option 3?
Thank you.
Last edited on
you should post the code you are working with and show us where you are stuck.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>

int main( void )
{
printf("Welcome to\nBIGSALE mall!\n");

int year;
printf("Please enter your year of birth \n");
scanf("%d",&year);

int productcode, quantity_sold;
int productcode1, quantity_sold1, Total1, Product_unit_price1 = 45.20;
int productcode2, quantity_sold2, Total2, Product_unit_price2 = 14.50;
int productcode3, quantity_sold3, Total3, Product_unit_price3 = 3.45;
int productcode4, quantity_sold4, Total4, Product_unit_price4 = 7.80;

printf("Enter product code(enter 1 to 4)(enter -1 to exit) \n");
scanf("%d", &productcode);

while(productcode != -1) //Once started, this loop will never finish. Nothing within the loop modifies the value of productcode. 
{
if(productcode == 1)
{
printf("Please enter quantity purchased");
scanf("%d", &quantity_sold1);

}
else if (productcode == 2)
{
printf("Please enter quantity purchased");
scanf("%d", &quantity_sold2);

}
else if (productcode == 3)
{
printf("Please enter quantity purchased");
scanf("%d", &quantity_sold3);

}
else if (productcode == 4)
{
printf("Please enter quantity purchased");
scanf("%d", &quantity_sold4);

}
else
{
printf("The code does not exist. Please try again!");
}

}

//printf("Enter quantity sold \n");
//scanf("%d", &Quantity_Sold);

return 0;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdio.h>

int main( void )
{
float parkinghours;
float parkingcharge;

printf( "Enter total parking hours!\n" );
scanf( "%f", &parkinghours );

if(parkinghours <=3){
parkingcharge = 2.00;
}

else if(parkinghours >=3){
parkingcharge = 2.00 + 0.50* //This is just left open and is going to cause an error 
}//You also need to add a closing brace here. 

printf ( "Total parking hour is %.2f\n", parkinghours);

return 0;

}
Last edited on
Use code tags. Under "format" - http://www.cplusplus.com/articles/jEywvCM9/
Is there any mistake in my code, it seems like I'm forcing the user to choose Option 1 but I'm supposed to let the user to choose by his own willingly. How do I correct it? I'm also having problem with Option 3, how do I continue?
Thank you :)
The requirements are asking you to display a menu. I see no such menu.

the program should allow user to choose from the 4 options below:

Option 1: Enter products purchased
Option 2: Enter parking hours
Option 3: Calculate and print the total bill
Option 4: Exit


The program should read in the customer’s total parking hours.

You have two main() functions. As I read the requirements, you should have a single program that displays a menu.

Option 3 requirements:
Your program should calculate and display the total bill in a neat format by listing out:

I see nowhere that you're calculating the total bill.

Note: Your program should use a switch statement to determine the option chosen by the user.

I see no switch statement in your code.

Since I think you're having trouble understanding the instructions, here are some specifics.

1) Change the first snippet to a function such as enter_product_code().
2) Chagne the second snippet to a functionsuch as enter_parking_charges().
3) Write a new function to print the bill. Note for this you will need an array to keep track of the number of each product code purchased.
4) Write a menu function which prompts the user for an option, then calls the appropriate function.
5) Write a new main() that loops on calling your menu function.

edit: Added #4, revised what is now #5.


Last edited on
I'm still in confusion, can anybody show me the right solution?
We're not going to write your program for you.

Do you understand functions and how to use them?

Follow the specifics I gave you in my previous post. I've updated them slightly.
Never mind then, thank you anyway.
Topic archived. No new replies allowed.