• 100% Satisfaction Guarantee
Category: Homework
Satisfied Customers: 1889
Experience:  Inner-city high school substitute teacher. Degrees in mathemetics, accounting, and education. Years and years of tutoring.
29937297
Ray Atkinson is online now

# Create a QBasic program that a numeric value and return the

Create a QBasic program that a numeric value and return the number of thousand,hundred,tens and units it contained.
the numeric value entered must be between 0 and 99999 inclusive.

Ray Atkinson :

I want to make sure I understand. You want to have the user input a number and have the program return the number of thousands, the number of hundreds, the number of tens, and the number of ones?

Customer:

so please work out an example for me. let say:

Customer:

INPUT:12000

Customer:

OUTPUT:

Customer:

Thousand: 12

Customer:

how wilthe program look like?

Ray Atkinson :

Do you want it to say "Hunderds: 0" or suppress it?

Ray Atkinson :

should it catch if the number is XXXXX an integer?

Customer:

pls both if u don't mind

Ray Atkinson :

Not a problem.

Ray Atkinson :

Do you want me to explain the run of the program, or just type it up?\

Customer:

type it then explain

Ray Atkinson :

Ok, give me a couple minutes, and I will type up a word file.

Customer:

ok i will be waiting

Ray Atkinson :

start: Input x

if x<0 or x>99999 or x<>int(x) then goto start

q=int(x/1000): if q>0 then print “Thousands:”; q: x=x-1000*q

q=int(x/100): if q>0 then print “Hundreds:”;q: x=x-100*q

q= int(x/10): if >0 then print “Tens:”; q: x=x-10*q

if x>0 then print “Ones:”; x

Ray Atkinson :

The first line puts a label and asks for input

Customer:

ok

Ray Atkinson :

the second catches negative number, numbers that are too large, and non-integers

Ray Atkinson :

the next line calls the number of thousands Q and prints how many there are, and reduces x by that many thousands.

Ray Atkinson :

the next lines do the same for hundreds, tens, and ones.

Ray Atkinson :

oops. I missed a q on the "tens" line.

Customer:

ok

Ray Atkinson :

I'm sure you can make it look fancier with a message of some kind on line 2 and some more wording with the messages, of you wanted.

Ray Atkinson :

You also probably want a better prompt for the user than just a ? for them to input the number.

Customer:

ok so basically am am i doing a division operation?

Ray Atkinson :

I just gave the skeleton on the program.

Customer:

yeah i konw

Ray Atkinson :

"int" returns the integer of a division problem.

Customer:

thanks let me work my way around it and get back to u should i not get something.

Ray Atkinson :

If you start with a number like 14358, the first line divides that by 1000, gets 14.358 and int makes it 14.

Ray Atkinson :

it prints the 14, and then takes 14*1000 away from x, so 14358-14000=358

Ray Atkinson :

Hmmm. You don't want it to say that there are 143 hundreds in that example, so you?

Ray Atkinson :

You want 14 thousands, 3 hundred, 5 tens, and 8 ones, right?

Customer:

yes

Ray Atkinson :

oh, good. I w2as afraid I misunderstood.

Ray Atkinson :

I will be here most of the day if you have any questions. When you are satisfied, please remember to rate my answer.

Customer:

so x is what the person will input right

Ray Atkinson :

yes.

Can you not see the solution above?

start: Input x

if x<0 or x>99999 or x<>int(x) then goto start

q=int(x/1000): if q>0 then print "Thousands:"; q: x=x-1000*q

q=int(x/100): if q>0 then print "Hundreds:";q: x=x-100*q

q= int(x/10): if >0 then print "Tens:"; q: x=x-10*q

if x>0 then print "Ones:"; x

Customer: replied 4 years ago.

thanks so much

You are quite welcome. I'm glad I could help.
Customer: replied 4 years ago.

hi good day