How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask .Paul Your Own Question
.Paul
.Paul, Computer Software Engineer
Category: Programming
Satisfied Customers: 44
Experience:  15 years visual basic experience
13558067
Type Your Programming Question Here...
.Paul is online now
A new question is answered every 9 seconds

Design a While loop that lets the user enter a number.

This answer was rated:

Design a While loop that lets the user enter a number. The number should be multiplied by 10, and the result stored in a variable named product. The loop should iterate as long as product contains a value less than 100.
try this:

declare integer product
declare integer number

product = 0

do while product < 100
   display "Enter a number"
   input number
   product = product + number * 10
loop

display product
was that how you expected it?

could you post the question as it is in the book? i've had this question before + i thought it was slightly different...
Customer: replied 8 years ago.
that looks right but how does the program end. I also have about 9 more questions can you help
when you enter a number it multiplies it by 10 + adds it to product. thats the part i'm not sure of. should product just contain the number * 10 or the running total?

when product is greater than 99 the program exits the loop, and the program ends.

yes i can help with your other questions. usually you'd put them in a new question, with a reasonable value (mark it "for .Paul" in the subject), or i can answer them in this thread for a bonus.
Customer: replied 8 years ago.

the book question is as stated exactly how written in the first question.

how much is the bonus total cost for all 10 questions.

this is the answer to the first question then:

declare integer product
declare integer number

product = 0

do while product < 100
display "Enter a number"
input number
product = number * 10
loop

.Paul and other Programming Specialists are ready to help you

You can post your questions + i'll get started on them.

Customer: replied 8 years ago.

Design a For loop that calculates the total of the following series of numbers:

1/30 + 2/29 + 3/28 + ... 30/1

declare decimal result

result = 0

for x = 1 to 30
    result = result + x / (31 - x)
next

display result
Customer: replied 8 years ago.

Convert the While loop in the following code to a Do-While loop:

Declare Integer x = 1

While x > 0

Display "Enter a number"

Input x

End While

Declare Integer x = 1

do While x > 0

Display "Enter a number"

Input x

loop
Customer: replied 8 years ago.

Design a program that displays a table of the centigrade temperatures 0 through 20 and their Fahrenheit equivalents. The formula for converting a temperature from centigrade to Fahrenheit is

9

F= --- C+32

5

Where F is the Fahrenheit temperature and C is the Centigrade temperature. Your program must use a loop to display the table.

declare string msg

msg = ""

For C = 0 To 20
    msg = msg & C & "C" & vbTab & (C * (9 / 5) + 32) & "F" & vbnewline
Next

display msg
Customer: replied 8 years ago.

Design a program with a loop that lets the user enter a series of numbers. The user should enter -99 to signal the end of a series. After all the numbers have been entered, the program should display the largest and smallest numbers entered.

declare integer largest
declare integer smallest
declare integer number

largest = Integer.MinValue
smallest = Integer.MaxValue
number = 0

do while number <> -99
   display "Enter a number"
   input number
   If number <> -99 And number > largest Then largest = number
   If number <> -99 And number < smallest Then smallest = number
loop

display "smallest = " & smallest
display "largest = " & largest
Customer: replied 8 years ago.
write a pseudocode statement that generates a random number in the range of 1 through 100 and assigns it to a value named rand.
Dim rand As Integer
rand = 100 * Rnd() + 1
Customer: replied 8 years ago.

Design a function named timesTen that accepts an Integer argument. When the function is called, it should return the value of its argument multiplied times 10.

Function timesTen(number As Integer) As Integer
    Return number * 10
End Function
Customer: replied 8 years ago.

Design a function named getFirstName that ask the user to enter his or her first name, and returns it.

Function getFirstName() as String
    declare string name
    display "Enter your first name."
    Input name
    Return name
End Function
Customer: replied 8 years ago.

In physics, an object that is in motion is said to have kinetic energy. The following formula can be used to determine a moving object's kinetic energy:

KE = 1/2mv^2

The variables in the formula are as follows: KE is the kinetic energy, m is the objects mass in kilograms, and v is the object's velocity, in meters per second.

Design a function named kineticEnergy that accepts an object's mass (in kilograms) and velocity (in meter per second) as arguments. The function should return the amount of kinetic energy that the object has. Design a program that ask the user to enter values for mass and velocity, and then calls the kineticEnergy function to get the object's kinetic energy.

Declare integer mass
Declare integer velocity

display "Enter mass."
Input mass
display "Enter velocity."
Input velocity

Display KineticEnergy(mass,velocity)

Function KineticEnergy(m As Integer, v As Integer)
    Return 1 / 2 * m * v ^ 2
End Function
Customer: replied 8 years ago.

Design a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows.

(1) When the program begins, a random number in the range of 1 through 3 is generated. If the number is ***** then the computer has chosen rock. If the number is ***** then the computer has chosen paper. If the number is ***** then the computer has chosen scissors. (Don't display the computer's choice yet.)

(2) The user enters his or her choice of "rock," "paper," or "scissors" at the keyboard.

(3) The computer's choice is displayed.

(4) The program should display a message indicating whether the user or the computer was the winner. A winner is selected according to the following rules:

  • If one player chooses rock and the other player chooses scissors, the rock wins (The rock smashes the scissors.)
  • If one player chooses scissors and the other player chooses paper, then scissors wins. (Scissors cuts paper.)
  • If one player chooses paper and the other player chooses rock, then paper wins. (Paper wraps rock.)
  • If both players make the same choice, the game must be played again to determine the winner.
Declare integer rand
rand = 3 * Rnd() + 1
Declare integer choice
Display "Enter your choice. (Rock = 1, Paper = 2, Scissors = 3)"
Input choice
Declare string pcChoice
Select Case rand
    Case 1
        pcChoice = "Rock"
    Case 2
        pcChoice = "Paper"
    Case 3
        pcChoice = "Scissors"
End Select

Display "Computer chose: " & pcChoice

If rand = choice Then
    Display "No winner."
End If

If rand = 1 And choice = 3 Then 'rock,scissors
    Display "Computer won."
ElseIf rand = 3 And choice = 1 Then 'scissors,rock
    Display "You won."
End If

If rand = 3 And choice = 2 Then 'scissors,paper
    Display "Computer won."
ElseIf rand = 2 And choice = 3 Then 'paper,scissors
    Display "You won."
End If

If rand = 2 And choice = 1 Then 'paper,rock
    Display "Computer won."
ElseIf rand = 1 And choice = 2 Then 'rock,paper
    Display "You won."
End If
.Paul and other Programming Specialists are ready to help you
Customer: replied 8 years ago.
yes how can I get you the next time I have questions

In the subject line of your question type "for .Paul"

thanks again

Related Programming Questions