d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Basic C - Cash Register
Prev12
Add Reply New Topic New Poll
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Feb 6 2013 12:31pm
edit

This post was edited by Eep on Feb 6 2013 12:32pm
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Feb 6 2013 01:11pm
in class atm hard to focus on this sec ><

your nested loop ONLY returns back to the beginning when validCode == 1, just FYI. So that shouldn't surprise you. (because your code never sets validCode = 1 EVER)

your outer loop will keep looping the nested loop as long as code is not 0 or not 00 and it will keep starting at Enter Item Code

This post was edited by Eep on Feb 6 2013 01:25pm
Member
Posts: 2,478
Joined: Jan 4 2007
Gold: 7,545.00
Feb 6 2013 02:09pm
Your code is quite confusing.
I think it would help if you wrote out in English what you want the program to do.

Here are some issues I see right off the bat, but I don't think this will help you any since your do whiles are incorrect imo.

Code
if (code < 10000 && code > 99999)


I'd like to see a number that is both less than 10000 and greater than 99999 :)

I think you meant || (or) here.

Also, make sure to initialize validCode = 1;

Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Feb 6 2013 03:44pm
Quote (DirtyRasa @ Feb 6 2013 03:09pm)
Your code is quite confusing.
I think it would help if you wrote out in English what you want the program to do.

Here are some issues I see right off the bat, but I don't think this will help you any since your do whiles are incorrect imo.

Code
if (code < 10000 && code > 99999)


I'd like to see a number that is both less than 10000 and greater than 99999 :)

I think you meant || (or) here.

Also, make sure to initialize validCode = 1;


I noticed that logic error too but I was like half asleep in my java class and didn't realize if it was something he intended or not LOL
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 6 2013 04:06pm
Quote (Eep @ Feb 6 2013 05:44pm)
I noticed that logic error too but I was like half asleep in my java class and didn't realize if it was something he intended or not LOL


how can a logic error ever be considered "intended"
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Feb 6 2013 04:36pm
Quote (AbDuCt @ Feb 6 2013 05:06pm)
how can a logic error ever be considered "intended"


because when I first looked at it I thought it was an error but then I looked at it again and was like no obviously he intends this

it was more of me not realizing it
Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll