0% found this document useful (0 votes)
45 views5 pages

Group Assignment # 3: Code For POS Machine

The document contains the code for a point of sale (POS) machine. It includes functions for prompting the user to enter a passcode, printing a menu, getting product prices from barcodes, performing new sales transactions, and tracking the total sales for the day. The main function runs a loop that displays the menu, gets a choice from the user, and either performs a new sale, ends the day to print totals, or exits the program. The code was written by two students for a group assignment.

Uploaded by

Jibran Ansari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views5 pages

Group Assignment # 3: Code For POS Machine

The document contains the code for a point of sale (POS) machine. It includes functions for prompting the user to enter a passcode, printing a menu, getting product prices from barcodes, performing new sales transactions, and tracking the total sales for the day. The main function runs a loop that displays the menu, gets a choice from the user, and either performs a new sale, ends the day to print totals, or exits the program. The code was written by two students for a group assignment.

Uploaded by

Jibran Ansari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Group Assignment # 3

Code for POS Machine:

#include <iostream>
using namespace std;

void printMenu()
{
cout << "Please choose from the following list" << endl;
cout << "1. New Sale" << endl;
cout << "2. End Day" << endl;
cout << "3. Exit" << endl;
cout << "";
}
bool verifyPasscode(int passcode)
{
return passcode == 1234;
}
int promptPasscode()
{
int passcode;
cout << "Please enter the PIN " << endl;
cin >> passcode;
return passcode;
}
void userLogin()
{

int userCode = promptPasscode();


while (!verifyPasscode(userCode))
{
cout << "Passcode incorrect" << endl;
userCode = promptPasscode();
}

double getPrice(int bar, double& price){

if (bar == 123) price = 10.5;


else if (bar == 124) price = 5.99;
else if (bar == 125) price = 1.99;
else if (bar == 126) price = 0.99;

return price;
}

double NewSale()
{
double total = 0;
int bar=0;
double price;

double change;

while (bar != -1){

cout << "Enter Barcode: ";


cin >> bar;
getPrice(bar, price);
cout << price << endl;
total = total + price;
cout << "Total: " << total << endl;
}

cout << "Enter the ammount paid: " << endl;


cin >> change;
cout << endl;
change = change - total;
cout << "Change " << change << endl << endl;

return total;

int main(int argc, const char * argv[]){

userLogin();
int choice = 0;

double daytotal = 0.0;

while (choice != 2)
{
printMenu();
int choice;
cin >> choice;
switch (choice)
{
case 1:
daytotal += NewSale();
break;
case 2:
cout << "Total for Day " << daytotal << endl;
break;
case 3:
return 0;
break;
default:
cout << "Wrong Choice" << endl;
}
}

return 0;
}

Done by:

Jibran Ansari 1044736


Saeed Abdul Majeed - 1045482

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy