Posts: 6
Threads: 1
Joined: Oct 2020
Oct-13-2020, 05:47 PM
(This post was last modified: Oct-13-2020, 05:47 PM by duddey.)
I need help a python code that asks what is below kind of struggling to put it together.
(You need to keep track of the amount of money that comes in from all of the stores. To accommodate this situation you decide to make a python program that will ask you the location/name of each store you manage. For each store, the program will ask that you enter in the following values: 100's, 50's, 20's, 10's 5's, 1's, quarters, dimes, nickles, and pennies, the program will take those values and add them to give the store total. The program will then take all the store totals and will calculate a grand total for all stores. Finally the program should ask the user if they want to save the information, if the user answers yes, the program should save the data to a .txt file.
Variables for the program should be named according to the data it represents. Comments need to be entered so that anyone who looks at the code can figure out what is happening. Error traps need to be used to validate data that is entered. Remember to keep the program as simple as possible, and add complexity if desired only after the core program works.
The use of pseudocode will be invaluable for working out the logic of the program.python code that is going to be rather long any help is appreciated.)
Posts: 1,583
Threads: 3
Joined: Mar 2020
What have you tried so far? Is there something you're stuck with? We can help you with problems, but we're not going to write the program for you. Is this a homework assignment?
Posts: 6
Threads: 1
Joined: Oct 2020
(Oct-13-2020, 07:10 PM)bowlofred Wrote: What have you tried so far? Is there something you're stuck with? We can help you with problems, but we're not going to write the program for you. Is this a homework assignment? It is just something I am doing for fun. stock on getting the code for the name and location of the stores as well as asking if the user wants to save in text file that I don't know where to start.
Posts: 1,950
Threads: 8
Joined: Jun 2018
(Oct-14-2020, 12:25 AM)duddey Wrote: It is just something I am doing for fun. /../ I don't know where to start.
There are different ways to define 'fun' but for assignment where I have no idea how to start I would use totally different sequence of words.
But about task at hand. For me there is ambiguity in wording: "make a python program that will ask you the location/name of each store you manage. For each store, the program will ask that you enter in the following values: 100's, 50's, 20's, 10's 5's, 1's, quarters, dimes, nickles, and pennies". Should I ask first for names of all stores and after that quantities of notes/coins in every store or should I ask one-by-one: store name and quantities of notes/coins in this store and after that repeat it with the next store.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Posts: 6
Threads: 1
Joined: Oct 2020
Oct-14-2020, 04:38 PM
(This post was last modified: Oct-14-2020, 04:39 PM by duddey.)
(Oct-14-2020, 02:13 PM)perfringo Wrote: (Oct-14-2020, 12:25 AM)duddey Wrote: It is just something I am doing for fun. /../ I don't know where to start.
There are different ways to define 'fun' but for assignment where I have no idea how to start I would use totally different sequence of words.
But about task at hand. For me there is ambiguity in wording: "make a python program that will ask you the location/name of each store you manage. For each store, the program will ask that you enter in the following values: 100's, 50's, 20's, 10's 5's, 1's, quarters, dimes, nickles, and pennies". Should I ask first for names of all stores and after that quantities of notes/coins in every store or should I ask one-by-one: store name and quantities of notes/coins in this store and after that repeat it with the next store.
Yes the program should ask for the names of the stores first and then calculate the amount of money for that store and then combine the totals of all the stores one would manage. I have no idea where to start just getting a start on the program would help.
Posts: 6
Threads: 1
Joined: Oct 2020
values = input("Input the names of the stores you work at : ")
list = values.split(",")
tuple = tuple(list)
print('name of stores')
int main ()
float amtDue = 0;
float amtGiven = 0;
float balAmount =0;
float twenty = 20.00
float ten = 10.00;
float five = 5.00;
float one = 1.00;
float quarter = .25;
float dime = .10;
float nickel = .05;
float penny = .01;
printf ("Enter the Amount Due: ");
scanf ("%f", &amtDue);
printf ("Enter the Amount Given: ");
scanf ("%f", &amtGiven);
balAmount = amtDue - amtGiven;
printf ("Change Due: $ %f", balAmount);
// This is where I really don't know the code but put what my best idea is something like
float modTwenty = amtbalance % twenty;
float modTen = modTwenty % ten;
// and so on down the line, I can figure out the float or int once I am behind my compiler
// I am using float because I am using MOD and want the result to be true, then using %d to printf the int so it doesn't say something like 2.3 twenties which is impossible
printf ("Twenties: %d \nTens: %d", modTwenty, modTen);
system ("pause");
return 0;
}
with open('outfile.txt', 'w') as outfile:
print >>outfile, 'Data collected on:', input['header']['timestamp'].date()
This is what I came up with but I don't think this is any where near what I need and I am getting a syntax error.
Posts: 1,950
Threads: 8
Joined: Jun 2018
You can't write javasque and expect it work in Python. You should learn Python syntax and then write valid Python code.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Posts: 6
Threads: 1
Joined: Oct 2020
(Oct-15-2020, 04:20 AM)perfringo Wrote: You can't write javasque and expect it work in Python. You should learn Python syntax and then write valid Python code.
OK
Posts: 6
Threads: 1
Joined: Oct 2020
pennies = int(input("Enter pennies:"))
nickels = int(input("Enter nickels:"))
dimes = int(input("Enter dimes:"))
quarters = int(input("Enter quarters:"))
print("You entered:")
print("\tPennies:" , pennies)
print("\tNickels:" , nickels)
print("\tDimes:" , dimes)
print("\tQuarters:" , quarters)
total_value = get_total(pennies, nickels, dimes, quarters)
v_Dollars, v_Cents = divmod(total_value, 1)
print("Total = ${:,.2f}".format(total_value))
print("You have {:,} dollar(s) and {:.2f} cent(s)".format(int(v_Dollars), v_Cents))
def get_total(pennies, nickels, dimes, quarters):
pennies = (.01 * pennies);
nickels = (.05 * nickels);
dimes = (.10 * dimes);
quarters = (.25 * quarters);
total_value = pennies + nickels + dimes + quarters
return total + value
with open('outfile.txt', 'w') as outfile:
print >>outfile, 'Data collected on:', input['header']['timestamp'].date()
I changed things around and came up with this instead.
Posts: 33
Threads: 7
Joined: Oct 2020
If it were my program, I would use arrays where each array element would be for a particular store.
Maybe start something like below. Then, when asking for the information, use the array index to keep things in order.
To add it all up, just do the math. To write it out, use the index.
Or, think about multi dimensional arrays!
from array import *
StoreName = array('c',[' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',])
StoreNumber = array('i',[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
Twenties = array('i',[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
Tens = array('i',[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
Fives = array('i',[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
Twos = array('i',[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
Ones = array('i',[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
Quarters = array('i',[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
|