Sponsored Content
Full Discussion: Cash Register Change Program
Top Forums Programming Cash Register Change Program Post 302927160 by gandolf989 on Monday 1st of December 2014 08:51:58 AM
Old 12-01-2014
You might want to start with how do you make change. You can use a floor or truncate function with division to tell how much of a certain currency you will give as change. Subtract the value of that currency from the change that needs to be given and continue on with the next lower currency until you get to cents. Which is where you stop. So if you owe $61.97 in change see what steps you need to follow to give proper change. With SQL I would do the following:

Code:
SQL> select floor(61.97/20) number_of_twenties,
  2  61.97-(20*floor(61.97/20)) remaining_change from dual;

NUMBER_OF_TWENTIES REMAINING_CHANGE
------------------ ----------------
                 3             1.97
SQL> select floor(1.97/10) number_of_tens,
  2  1.97-(10*floor(1.97/10)) remaining_change from dual;

NUMBER_OF_TENS REMAINING_CHANGE
-------------- ----------------
             0             1.97
SQL> select floor(1.97/5) number_of_fives,
  2  1.97-(5*floor(1.97/5)) remaining_change from dual;

NUMBER_OF_FIVES REMAINING_CHANGE
--------------- ----------------
              0             1.97
SQL> select floor(1.97/1) number_of_ones,
  2  1.97-(1*floor(1.97/1)) remaining_change from dual;

NUMBER_OF_ONES REMAINING_CHANGE
-------------- ----------------
             1              .97
SQL> select floor(.97/.25) number_of_quarters,
  2  .97-(.25*floor(.97/.25)) remaining_change from dual;

NUMBER_OF_QUARTERS REMAINING_CHANGE
------------------ ----------------
                 3              .22

SQL> select floor(.22/.10) number_of_dimes,
  2  .22-(.1*floor(.22/.10)) remaining_change from dual;

NUMBER_OF_DIMES REMAINING_CHANGE
--------------- ----------------
              2              .02

SQL> select floor(.02/.05) number_of_nickels,
  2  .02-(.05*floor(.02/.05)) remaining_change from dual;

NUMBER_OF_NICKELS REMAINING_CHANGE
----------------- ----------------
                0              .02

At this point multiply by 100 for the number of pennies. Once you know the method of figuring out change, then figure out what language you can code it in. You might try Perl or Python this. You can use an array or set of arrays to store the currency and the proper order to do the computation with.
This User Gave Thanks to gandolf989 For This Post:
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

UNIX Program Change Question

I am an IT auditor with a big 4 accounting firm and am cur the process of conducting an application program change audit for a large public company related to Sarbanes Oxley. This is my first time using this forum and need some assistance in verifying a fact that I believe to be true. My client... (1 Reply)
Discussion started by: mpp122
1 Replies

2. Shell Programming and Scripting

script/program to change the password ?

hi, Somebody have or known where i can find a perl small perl program to change the password. The point: First it verify is the user exist, checking the old typed password and replace it with new. The passwords must be encoded. Thanks, very much! (0 Replies)
Discussion started by: kad
0 Replies

3. UNIX for Advanced & Expert Users

Finding register set being used in program

How can i find( or list) contents of all registers being used by my program? Is there any system call or library available for this?:confused: At runtime in my c/c++ program. At runtime using may be some assembly hack!!!!!!!!!!! (2 Replies)
Discussion started by: amit gangarade
2 Replies

4. Programming

Change Pseudo Code to C Program (print and fork)

I am very new at programming and this is probably an easy question, but I am desperate. I need to change this low level code into a C program that I can run so I can print out every "A" that appears with the fork() command. You help is greatly appreciated. PRINT A p=fork() if( p == 0) {... (0 Replies)
Discussion started by: tpommm
0 Replies

5. UNIX for Dummies Questions & Answers

Create a simple ATM (Cash machine simulation)

I need to create a simple ATM (Cash machine simulation in unix) which shows a welcome screen, then a login screen to enter 3 users details. help please on the coding The users details need to be in a txt file: the details are: (PIN No, First name last name, Account number, Balance, Histrosy) ... (1 Reply)
Discussion started by: oobla01
1 Replies

6. Homework & Coursework Questions

Simulate a ATM (cash machine) on UNIX(Putty) using scritps

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I need to create a simple ATM (Cash machine simulation in unix) which shows a welcome screen, then a login screen... (2 Replies)
Discussion started by: oobla01
2 Replies

7. Debian

Change the privileges needed to run a program

Hi everyone, I have an issue with a project of mine. I have to run a program on a terminal which requires to be logged in as su to have it run it. Given that I'm having problem to use expect to give the password I'd like to change the privilege of that program from SU to normal user ( I have the SU... (13 Replies)
Discussion started by: gaisselick87
13 Replies

8. UNIX for Dummies Questions & Answers

Change to different user id inside a program

Hi, There is a process ( built in C/C++) which starts with my user id and I need to execute a specific function with a different user id. Is there any api so that I provide userid, passwd and the next instance the process will have the new user id privileges. - Pranav (3 Replies)
Discussion started by: k_pranava
3 Replies
__PPC_SET_PPR_MED(3)					     LinuxProgrammer's Manual					      __PPC_SET_PPR_MED(3)

NAME
__ppc_set_ppr_med, __ppc_set_ppr_very_low, __ppc_set_ppr_low, __ppc_set_ppr_med_low, __ppc_set_ppr_med_high - Set the Program Priority Reg- ister SYNOPSIS
#include <sys/platform/ppc.h> void __ppc_set_ppr_med(void); void __ppc_set_ppr_very_low(void); void __ppc_set_ppr_low(void); void __ppc_set_ppr_med_low(void); void __ppc_set_ppr_med_high(void); DESCRIPTION
These functions provide access to the Program Priority Register (PPR) on the Power architecture. The PPR is a 64-bit register that controls the program's priority. By adjusting the PPR value the programmer may improve system throughput by causing system resources to be used more efficiently, especially in contention situations. The available unprivileged states are cov- ered by the following functions: * __ppc_set_ppr_med() sets the Program Priority Register value to medium (default). * __ppc_set_ppr_very_low() sets the Program Priority Register value to very low. * __ppc_set_ppr_low() sets the Program Priority Register value to low. * __ppc_set_ppr_med_low() sets the Program Priority Register value to medium low. The privileged state medium high may also be set during certain time intervals by problem-state (unprivileged) programs, with the following function: * __ppc_set_ppr_med_high() sets the Program Priority to medium high. If the program priority is medium high when the time interval expires or if an attempt is made to set the priority to medium high when it is not allowed, the priority is set to medium. VERSIONS
The functions __ppc_set_ppr_med(), __ppc_set_ppr_low() and __ppc_set_ppr_med_low() are provided by glibc since version 2.18. The functions __ppc_set_ppr_very_low() and __ppc_set_ppr_med_high() first appeared in glibc in version 2.23. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +---------------------------+---------------+---------+ |Interface | Attribute | Value | +---------------------------+---------------+---------+ |__ppc_set_ppr_med(), | Thread safety | MT-Safe | |__ppc_set_ppr_very_low(), | | | |__ppc_set_ppr_low(), | | | |__ppc_set_ppr_med_low(), | | | |__ppc_set_ppr_med_high() | | | +---------------------------+---------------+---------+ CONFORMING TO
These functions are nonstandard GNU extensions. NOTES
The functions __ppc_set_ppr_very_low() and __ppc_set_ppr_med_high() will be defined by <sys/platform/ppc.h> if _ARCH_PWR8 is defined. Availability of these functions can be tested using #ifdef _ARCH_PWR8. SEE ALSO
__ppc_yield(3) Power ISA, Book II - Section 3.1 (Program Priority Registers) GNU C Library 2017-09-15 __PPC_SET_PPR_MED(3)
All times are GMT -4. The time now is 01:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy