Welcome Guest ( Log In | Register )

5 Pages  1 2 3 > » Bottom

Outline · [ Standard ] · Linear+

 Newbie, junior, senior programmer, Simple POS system

views
     
TSWongGei
post Feb 20 2023, 12:29 PM, updated 3y ago

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
user posted image

Requirement,

Create a simple POS system that take in customer order and calculates the total amount of the order.

This seems like a simple question that suits 1st assignment of the programming language class.

Let see how the Newbie, Junior Programmer, Senior Programmers' work.

And discuss why the program classified as such (N,J,S)

This post has been edited by WongGei: Feb 20 2023, 12:30 PM
angch
post Feb 20 2023, 07:06 PM

On my way
****
Junior Member
636 posts

Joined: Jul 2006
CODE

# Define the menu with prices
menu = {
   "Hamburger": 5.00,
   "Cheeseburger": 6.00,
   "Hot Dog": 4.00,
   "French Fries": 3.00,
   "Soda": 1.50,
   "Water": 1.00
}

# Initialize variables
order_total = 0.00
order_items = []

# Take customer order
while True:
   item = input("Please enter an item name (or 'done' to complete the order): ")
   if item.lower() == "done":
       break
   elif item in menu:
       order_items.append(item)
       order_total += menu[item]
       print(f"{item} added to order (total: ${order_total:.2f})")
   else:
       print("Sorry, that item is not on the menu.")

# Print order details
print("\nOrder Summary:")
for item in order_items:
   print(f"- {item}: ${menu[item]:.2f}")
print(f"Total: ${order_total:.2f}")


Creating a Point of Sale (POS) system can be useful for managing customer orders.
Having a menu with items and their prices is necessary.
As customers make their orders, the items and their prices are recorded in variables.
The total cost of the order is updated as each item is added to the order.
Getting input from the user to create the order is done with a loop.
Print out the order details and the total cost at the end.
To make the system more advanced, additional features could be added such as discounts or payment processing.

Editor's note: Asked it to do the last part instead of doing it manually.

This post has been edited by angch: Feb 21 2023, 12:02 PM
TSWongGei
post Feb 21 2023, 10:27 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(angch @ Feb 20 2023, 07:06 PM)
CODE

# Define the menu with prices
menu = {
   "Hamburger": 5.00,
   "Cheeseburger": 6.00,
   "Hot Dog": 4.00,
   "French Fries": 3.00,
   "Soda": 1.50,
   "Water": 1.00
}

# Initialize variables
order_total = 0.00
order_items = []

# Take customer order
while True:
   item = input("Please enter an item name (or 'done' to complete the order): ")
   if item.lower() == "done":
       break
   elif item in menu:
       order_items.append(item)
       order_total += menu[item]
       print(f"{item} added to order (total: ${order_total:.2f})")
   else:
       print("Sorry, that item is not on the menu.")

# Print order details
print("\nOrder Summary:")
for item in order_items:
   print(f"- {item}: ${menu[item]:.2f}")
print(f"Total: ${order_total:.2f}")


Chances are we can write the code
Here that we can ignore some of the data
At the image just because
There isn't much point for me to
Grab the tiny pixels of information my
Poor eyesight can read.
Text that can be copied and pasted is much better.
*
Reason:
Pros:
Data and Algorithm are separated. Data can be changed with out affecting the algorithm.
Con:
Still need to be compiled and deployed if any changes.

From my opinions,
This should be a Junior Programmer work.
silverhawk
post Feb 21 2023, 10:30 AM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


Its not as simple as it looks

The moment you have sets, things get really complicated. Are the sets only bundles? Do they have conditional requirements? are set values fixed or percentage off? coupon and voucher rules, etc
TSWongGei
post Feb 21 2023, 11:13 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(silverhawk @ Feb 21 2023, 10:30 AM)
Its not as simple as it looks

The moment you have sets, things get really complicated. Are the sets only bundles? Do they have conditional requirements? are set values fixed or percentage off? coupon and voucher rules, etc
*
Good questions. rclxms.gif

That's the questions that a senior programmer should ask before he/she even start coding.
flashang
post Feb 21 2023, 12:03 PM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


You might need to think about how to control if sold out,
which required inventory control.

For each order of "YOU TIAO"
ala carte / SET A / SET B / SET C / SET E
have to deduct the stock balance of product "YOU TIAO"

So your MENU / SET setup need to link to products.

Some product may have "optional", such as
Soya bean : "Cold / Hot", "no sugar", "standard", "less sugar", "extra sugar".
Porridge : "no spring onion", "extra egg".

Some products may have to do dispose before closing of the day.

smile.gif


cassian948
post Feb 21 2023, 12:11 PM

Enthusiast
*****
Junior Member
931 posts

Joined: Jan 2017
From: Kuala Lumpur
So, unless the customer explicitly orders a set, each item should charge individually and not automatically discounted as a set?
TSWongGei
post Feb 21 2023, 12:24 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(flashang @ Feb 21 2023, 12:03 PM)
You might need to think about how to control if sold out,
which required inventory control.

For each order of "YOU TIAO"
ala carte / SET A / SET B / SET C / SET E
have to deduct the stock balance of product "YOU TIAO"

So your MENU / SET setup need to link to products.

Some product may have "optional", such as
Soya bean : "Cold / Hot", "no sugar", "standard", "less sugar", "extra sugar".
Porridge : "no spring onion", "extra egg".

Some products may have to do dispose before closing of the day.

smile.gif
*
The question are mostly out of scoop.
Even the hot/cold, no sugar and etc wont affect the calculation of the price.

This is just a program that calculate the price of an order, not inventory control system.


TSWongGei
post Feb 21 2023, 12:30 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(cassian948 @ Feb 21 2023, 12:11 PM)
So, unless the customer explicitly orders a set, each item should charge individually and not automatically discounted as a set?
*
This is a very good question.
Imagine you are a customer, how you would like the system to have?
If you just like to have a You Tiao and your friend just like to have a Tau Fu Fa, how will you order?

I will qualify the question as a question that a junior programmer will ask cause it will still need to recompile the program every time changes happen?
flashang
post Feb 21 2023, 12:45 PM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


QUOTE(WongGei @ Feb 21 2023, 12:24 PM)
The question are mostly out of scoop.
Even the hot/cold, no sugar and etc wont affect the calculation of the price.

This is just a program that calculate the price of an order, not inventory control system.
*
Indeed, hot/cold, standard / large do not affect the price if using different product code.

Only add-on (extra egg, extra kaya) will affect the price.
Of course you could use side-order with different product code.

But the ordering UI / form and the preview/receipt might need to re-design.

P/S :
To have a better view of how good the ordering system is,
may be go to some cafe / shop / mcd,
take picture of their ordering slip / online order website / order kiosk,
and go through the whole process.

smile.gif



This post has been edited by flashang: Feb 21 2023, 01:01 PM
TSWongGei
post Feb 21 2023, 04:36 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(WongGei @ Feb 20 2023, 12:29 PM)
user posted image

Requirement,

Create a simple POS system that take in customer order and calculates the total amount of the order.

This seems like a simple question that suits 1st assignment of the programming language class.

Let see how the Newbie, Junior Programmer, Senior Programmers' work.

And discuss why the program classified as such (N,J,S)
*
After rolling my eye for 24 hours, finally the newbie vesion is out.
The program do what its suppose to do and should get full mark for the assignment.
Why I classify it as a newbie program.

1.) No seperation of data and algorithm
2.) Any changes require recompile , testing and deployment




Attached File(s)
Attached File  newbie.gz ( 1.04k ) Number of downloads: 13
FlierMate4
post Feb 21 2023, 04:52 PM

Getting Started
**
Validating
90 posts

Joined: Jan 2023
QUOTE(WongGei @ Feb 21 2023, 04:36 PM)
After rolling my eye for 24 hours, finally the newbie vesion is out.
The program do what its suppose to do and should get full mark for the assignment.
Why I classify it as a newbie program.

1.) No seperation of data and algorithm
2.) Any changes require recompile , testing and deployment
*
The C++ code is clean and straightforward, looks like it was written by a teacher, not by student. hmm.gif

user posted image

I took note that the total price is printed only after choosing "z" (exit).


This post has been edited by FlierMate4: Feb 21 2023, 08:23 PM
flashang
post Feb 21 2023, 11:32 PM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


QUOTE(WongGei @ Feb 21 2023, 04:36 PM)
After rolling my eye for 24 hours, finally the newbie vesion is out.
The program do what its suppose to do and should get full mark for the assignment.
Why I classify it as a newbie program.

1.) No seperation of data and algorithm
2.) Any changes require recompile , testing and deployment
*
How many marks you could get is depends on marking scheme,
and this is based on what are the expected work.

e.g.

working code : 50% (every major bug -10%)
use object : 15%
use inheritance : 10%
use struct : 10%
use switch case : 5%
load data from file, not variables : 10%

Note : program with bugs may have higher marks if more criteria are met.

Total : 100%

Grade :
0~20% F
21~40% E
41~49% D
50~70% C
71~80% B
81~90% A
91~100% A+

These are just some assumption.

smile.gif



This post has been edited by flashang: Feb 21 2023, 11:41 PM
TSWongGei
post Feb 22 2023, 10:52 AM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(flashang @ Feb 21 2023, 11:32 PM)
How many marks you could get is depends on marking scheme,
and this is based on what are the expected work.

e.g.

working code : 50% (every major bug -10%)
use object : 15%
use inheritance : 10%
use struct : 10%
use switch case : 5%
load data from file, not variables : 10%

Note : program with bugs may have higher marks if more criteria are met.

Total : 100%

Grade :
0~20% F
21~40% E
41~49% D
50~70% C
71~80% B
81~90% A
91~100% A+

These are just some assumption.

smile.gif
*
whistling.gif
TSWongGei
post Feb 23 2023, 04:46 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(WongGei @ Feb 21 2023, 04:36 PM)
After rolling my eye for 24 hours, finally the newbie vesion is out.
The program do what its suppose to do and should get full mark for the assignment.
Why I classify it as a newbie program.

1.) No seperation of data and algorithm
2.) Any changes require recompile , testing and deployment
*
After study for some time, a newbie learn how to separates data with algorithm and make the program more easy to change.

Still, need to recompile and deploy program every time changes involved.


Attached File(s)
Attached File  junior.gz ( 1.38k ) Number of downloads: 10
flashang
post Feb 23 2023, 11:16 PM

Casual
***
Junior Member
355 posts

Joined: Aug 2021


QUOTE(WongGei @ Feb 23 2023, 04:46 PM)
After study for some time, a newbie learn how to separates data with algorithm and make the program more easy to change.

Still, need to recompile and deploy program every time changes involved.
*
You could use "alacarte" as "Set" with only 1 item.

smile.gif


silverhawk
post Feb 23 2023, 11:20 PM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


QUOTE(WongGei @ Feb 21 2023, 12:30 PM)
This is a very good question.
Imagine you are a customer, how you would like the system to have?
If you just like to have a You Tiao and your friend just like to have a  Tau Fu Fa, how will you order?

I will qualify the question as a question that a junior programmer will ask cause it will still need to recompile the program every time changes happen?
*
Its a good question, not necessarily a "junior" question.

The one who defines that system is not the customer, but the company. From user perspective, they don't really care. Many POS still can't do auto sets, and in the past this is how some workers used to cheat money from the customer and company. They would quickly switch ala carte and set pricing so customer pays higher but they record as set in the system and pocket the difference. .
TSWongGei
post Feb 24 2023, 01:29 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(silverhawk @ Feb 23 2023, 11:20 PM)
Its a good question, not necessarily a "junior" question.

The one who defines that system is not the customer, but the company. From user perspective, they don't really care. Many POS still can't do auto sets, and in the past this is how some workers used to cheat money from the customer and company. They would quickly switch ala carte and set pricing so customer pays higher but they record as set in the system and pocket the difference. .
*
This is just an application. Depends on who and how it is used.
I used the above menu as a example is not a coincidentally. I was at one of the outlet last week. Was placing the order of a soya bean because I was thirty. Then I watch the cashier key in my order. Then I feel like a bit of hungry, so, I add-on a you tiao in my order.
The cashier just press one button (or move his hand once) to add my "you tiao" order. And I ask how much, surprisingly he quote me the set price instead of 2 alarcart order, without erasing my previous order and re-key in (No more moving hand nor fingers). It means the system can automatic give you offer of the set price when your alarcart meet the set requirement.
That inspire me to create a thread and discuss about this.

So far I haven't see any "codemaster" that can come out with the algorithm to do that.

TSWongGei
post Feb 24 2023, 01:39 PM

Regular
******
Senior Member
1,206 posts

Joined: Dec 2007
From: Kuala Lumpur
QUOTE(silverhawk @ Feb 23 2023, 11:20 PM)

The one who defines that system is not the customer, but the company. From user perspective, they don't really care. Many POS still can't do auto sets, and in the past this is how some workers used to cheat money from the customer and company. They would quickly switch ala carte and set pricing so customer pays higher but they record as set in the system and pocket the difference. .
*
To further answer your consideration, may be a POS system doesn't care if it is charged as a la cart or set. But the same algorithm can be used by a courier company or ship cargo. Imagine the price is a volume that require to fit an item (alacarte). There are only certain type of boxes (set). How many boxes are needed how to maximized the space utilization. The shipment company will pay you tons of money to come out with a program that can do that.
angch
post Feb 24 2023, 01:47 PM

On my way
****
Junior Member
636 posts

Joined: Jul 2006
QUOTE(WongGei @ Feb 24 2023, 01:29 PM)
It means the system can automatic give you offer of the set price when your alarcart meet the set requirement.
That inspire me to create a thread and discuss about this.

So far I haven't see any "codemaster" that can come out with the algorithm  to do that.
*
Not too hard, just need a combinatorial optimization solver after every addition of single orders.

A variation on: https://gist.github.com/angch/287342ca84f0ede4146d

Edit: I'll hack on it when I've time, but not anytime soon. Bookmarked.

This post has been edited by angch: Feb 24 2023, 01:56 PM

5 Pages  1 2 3 > » Top
 

Change to:
| Lo-Fi Version
0.0256sec    0.94    6 queries    GZIP Disabled
Time is now: 24th December 2025 - 01:08 PM