• 100% Satisfaction Guarantee
Chris Parker, Problem Solver
Category: Homework
Satisfied Customers: 2243
Experience:  Master of Computer Applications (MCA). BSc in Mathematics, Physics, and Computer Science.
4769983
Chris Parker is online now

# I need help in pseudocode for the following questions

### Resolved Question:

Algorithm

1. Design an algorithm that displays the following menuu gets the user's selection and validates the selectoin

1. Open a new document.
2. Close the current document
3. Print the current document
4. Exit the program

2. Design a case structure that can be used with the algorithm you designed for Algorithm workbench questions 1. The case structure should call a module named openDocument if the user selected item 1, should call a module named closeDocument if the user selected item 2 and should call a module named printDocument if the user selected item 3

3. Pute the algorithms that you designed for algorithm workbench questions 1 and 2 together inside a loop that redisplays the menu after the user's selected operation is performed or exits if the user selects item 4 from the menu

Programming

3. Geometry calculator

write a program that displays the following menu:
geometry calculator
1. calculate the area of a circle
2. calculate the area of a rectangle
3. calculatle the area of a triangle
4. quit
Submitted: 9 years ago.
Category: Homework
Expert:  Chris Parker replied 9 years ago.
HiCustomer

I can help you with this. Can I give this to you by tomorrow morning?

-Chris
Customer: replied 9 years ago.
Reply to XXXXX XXXXX's Post: No problem, thanks for your help. Don't want to overwhelm you, but may I send you some more. I will deposit some more money. Just let me know. Thanks
Expert:  Chris Parker replied 9 years ago.

-Chris
Expert:  Chris Parker replied 9 years ago.
HiCustomer

Below is the pseudocode for the four questions. If you find my response helpful, please click on the "Accept" button so that I get credit for helping you.

Regards,
Chris

=================================================================

1)

PRINT ‘1. Open a new document’
PRINT ‘2. Close the current document’
PRINT ‘3. Print the current document’
PRINT ‘4. Exit the program’

IF selection is NOT 1,2,3,or 4
PRINT ‘You entered an invalid selection. Please enter again.’
END IF

2)

PRINT ‘1. Open a new document’
PRINT ‘2. Close the current document’
PRINT ‘3. Print the current document’
PRINT ‘4. Exit the program’

IF selection is NOT 1,2,3,or 4
PRINT ‘You entered an invalid selection. Please enter again.’
END IF

case 1: CALL openDocument

case 2: CALL closeDocument

case 3: CALL printDocument

3)

REPEAT

PRINT ‘1. Open a new document’
PRINT ‘2. Close the current document’
PRINT ‘3. Print the current document’
PRINT ‘4. Exit the program’

IF selection is NOT 1,2,3,or 4
PRINT ‘You entered an invalid selection. Please enter again.’
END IF

case 1: CALL openDocument
clearScreen()

case 2: CALL closeDocument
clearScreen()

case 3: CALL printDocument
clearScreen()

UNTIL selection is NOT EQUAL TO 4

4)

REPEAT

SELECT:

PRINT ‘Geometry Calculator’
PRINT ‘1. Calculate the area of a circle’
PRINT ‘2. Calculate the area of a rectangle’
PRINT ‘3. Calculate the area of a triangle’
PRINT ‘4. Quit’

IF selection is NOT 1,2,3,or 4
PRINT ‘You entered an invalid choice. Please enter again.’
GOTO SELECT
END IF

IF radius is NOT a +ve integer
END IF

PRINT circleArea
clearScreen()
GOTO SELECT

case 2: LENGTH:
PRINT ‘Enter length’
IF length is NOT a +ve integer
PRINT ‘You entered an invalid length. Please enter again.’
GOTO LENGTH
END IF

IF breadth is NOT a +ve integer
END IF

PRINT rectangleArea
clearScreen()
GOTO SELECT

case 3: BASE:
PRINT ‘Enter base’
IF base is NOT a +ve integer
PRINT ‘You entered an invalid base. Please enter again.’
GOTO BASE
END IF

HEIGHT:
PRINT ‘Enter height’
IF height is NOT a +ve integer
PRINT ‘You entered an invalid height. Please enter again.’
GOTO HEIGHT
END IF

triangleArea =1/2 x base x height
PRINT triangleArea
clearScreen()
GOTO SELECT

UNTIL choice is NOT EQUAL TO 4

===============================================================
Customer: replied 9 years ago.
Reply to XXXXX XXXXX's Post: Chris I send you some more. Thanks
Expert:  Chris Parker replied 9 years ago.
Thanks for the accept. Post your new questions here.

-Chris
Customer: replied 9 years ago.
1. Design a swap module that accepts two arguments of the Real data type and swaps them.

2. What algorithm does the following pseudocode perform?

Declare Integer maxElement
Declare Integer index

For maxElement = arraySize - 1 to 0 Step -1
For index = 0 to maxElement - 1
If array[index] > array[ index + 1] Then
Call swap (array[ index], array [ index + 1] )
End If
End for
End for

3.What algorithm does the following pseudocode perform?

Declare Integer index
Declare Integer scan
Declare Integer unsortedValue

For index = 1 To arraySize - 1
Set unsortedValue = array [index ]
Set scan = index

While scan ? 0 AND array [scan-1] < array [scan]
Call swap (array [scan-1], array [scan])
Set scan = scan - 1
End While

4.What algorithm does the following pseudocode perform?

Declare Integer startScan

Declare Integer minIndex
Declare Integer minValue
Declare Integer index

For startScan = 0 To arraySize - 2
Set minIndex = startScan
Set minValue = array [startScan]

For index = startScan + 1 To arraySize - 1
If array[ index] < minValue
Set minValue = array[ index]
Set minIndex = index
End If
End For

Call swap[ array[minIndex], array[ startScan])
End For

2. Sorted Names

Design a program that allows the user to enter 20 names into a String array Sort the array in asceding (alphabetical) order and display its contents

ch10

3. Design an algorithm that does the following: opens an output file with the external name number_list.dat uses a loop to write the numbers 1 though 100 to the file and then closes the file

4. Desgin an algorithm that does the following: opens the number_list.dat file that was created by the algorithm creataed in questions 3 reads all the numbers from the file and displays them, and then closes the file

6. The Springfork Amateur golf club has a tournament every weekend. The club president has asked you to design two programs.

1. A program that will read each players name and golf score as eyboard input, and then save these as records in a file named golf.dat *each record will have a file and displays them.

7. Modify program #2 that you wrote for Programming exercise 6 so it also displays the name of the player with the best lowest golf score. you do not not need to read the file into an array to use this technique however it can be adapted for use with a file.
Expert:  Chris Parker replied 9 years ago.
I notice that the same set of questions is posted in the Computer section. I am not part of that section, so I will be unable to answer there. I will opt-out of the new questions and give other experts a chance to assist you.

-Chris
Customer: replied 9 years ago.
Reply to XXXXX XXXXX's Post: I meant to send you the questions. What do I need to do to fix it?
Expert:  Chris Parker replied 9 years ago.

-Chris

Customer: replied 9 years ago.
Hi Chris...let me know if you can help me out.

1. What will the following program display?

Module main()
Declare Integer num = 0
Call showMe(num)
End Module

Module showMe(Integer arg)
If arg < 10 Then
Call showMe(arg + 1)
Else
Display arg
End If
End Module

2. What will the following program display?
Module main()
Declare Integer num = 0
Call showMe(num)
End Module

Module showMe(Integer arg)
Display arg
If arg < 10 Then
Call showMe(arg + 1)
End if
End Module

3. The following module uses a loop. Rewrite it as a recursive module that performs the same operation.

Module trafficeSign(int n)
While n > 0
Display "No Parking"
Set n = n - 1
End While
End Module

Recursive Power Method
5. Design a function that uses recursion to raise a number to a power. The function should accept two arguments: the number to be raised and the exponent. Assume that the exponent is a nonnegative integer.

Ackermann's Function
Ackermann's Function is a recursive mathematical algorithm that can be used to test how well a computer performs recursion. Design a function ackermann(m,n), which solves Ackermann's Function. Use the following logic in your function:

If m=0 then return n + 1
If n=0 then return ackerman(m - 1, 1)
Otherwise, return ackermann(m - 1, ackermann(m, n-1)
6.
Expert:  Chris Parker replied 9 years ago.

Your 6th question seems to have been cut-off. Could you please post it?

Thanks,

Chris

Customer: replied 9 years ago.
6. Ackermann's Function is a recursive mathematical algorithm that can be used to test how well a computer performs recursion. Design a function ackermann(m,n), which solves Ackermann's Function. Use the following logic in your function:
If m = 0 then return n + 1
If n+0 then return ackermann(m - 1,1)
Otherwise, return ackermann(m - 1, ackermann(m, n - 1))
Expert:  Chris Parker replied 9 years ago.

HiCustomer

Below is my response to your questions. Please click on "Accept" if you find my response helpful. Let me know if you need any modifications.

Thanks,

Chris

==============================================================

1)

The program will display 10.

2)

The program will display 0 1 2 3 4 5 6 7 8 9 10

3)

Module main()

Declare Integer n

Print ‘Enter n'
Call trafficSign (n)

End Module

Module trafficSign (Integer arg)

If(arg>0)
Print "No Parking"
n--
Call trafficSign (n)
End If

End Module

5)

Declare Integer result=1

Module main()

Declare Integer number
Declare Integer power

Input1:

Print ‘Enter number'

If number is XXXXX a positive integer
Print ‘You entered an invalid number. Please enter again.'
Goto Input1
End If

Input2:

Print ‘Enter power'

If power is NOT a positive integer
Print ‘You entered an invalid power. Please enter again.'
Goto Input2
End If

Call exponent (number,power)
Print ‘Result:' result

End Module

Module exponent (Integer number, Integer pow)

If(pow-1 >=0)
result=result*num
pow--
exponent(num,pow)
End If

End Module

6)

Module main()

Declare Integer m
Declare Integer n
Declare Integer result

result = Call ackermann(m,n)

Print ‘The value of Ackermann's function=' result
End Module

Module ackermann(Integer m, Integer n)
If (m == 0)
Return (n + 1)
Else If (n == 0)
Return (ackermann(m - 1,1))
Else
Return (ackermann(m - 1,ackermann(m,n - 1)));
End If
End If

End Module

==============================================================

Customer: replied 9 years ago.
1. Suppose myCar is the name of a class variable that references an object and go is the name of a method. (The go method does not take any arguments). Write a pseudocode statement that uses the myCar variable to call the method.

4. In pseudocode write the first line of the definition for a Poodle class. The class should extend the Dog class.

5. Look at the following pseudocode class definitions

Class Plant
Public Module message()
Display "I'm a plant."
End Module
End Class
Class Tree Extends Plant
Public Module message()
Display "I'm a tree."
End Module
End class

Given these class definitions, what will the folowing pseudocode display?

Declare Plant p
Set p = new Tree()
Call p.message()
Customer: replied 9 years ago.
1. Pet Class

Design a class named Pet, which should have the following fields:

name-The name field holds the name of a pet.
type-The type field holds the type of animal that a pet is. Example values are "Dog","Cat", and "Bird"
age-The age field holds the pet's age.

The Pet class should also have the following methods:

setName-The setName method stores a value in the name field.

setType-The setType method stores a value in the type field.

setAge-The setAge method stores a value in the age field.

getName- The getName method returns the value of the name field

gettype- The getType method returns the value of the type field

getAge-The getAge method returns the value of the age field.

Once you have deigned the class, design a program that creates an object of the class and prompts the user to enter the name, type and age of his or her pet. This data should be stored in the object. Use the objects accessor methods to retrieve the pet's name, type, and age and display this data on the screen
Customer: replied 9 years ago.
Personal Information Class

Design a class that holds the following personal data:; name, address, age, and phone number. Write appropriate accessor and mutator methods. Also design a program that creates three instances of the class. One instance should hold your information and the other two should hold your firends or family members information
Expert:  Chris Parker replied 9 years ago.
HiCustomer

Thanks for the questions. Do you need pseudocode for Pet Class and Personal Information Class or an actual program written in say C++?

Let me know and I will get these out to you to tomorrow.

Regards,
Chris
Customer: replied 9 years ago.
Pseudocode please and I will deposit the money tomorrow morning. Thanks for your assistance.
Expert:  Chris Parker replied 9 years ago.
HiCustomer

Regards,
Chris

================================================================

1. Suppose myCar is the name of a class variable that references an object and go is the name of a method. (The go method does not take any arguments). Write a pseudocode statement that uses the myCar variable to call the method.

Class Car

Public Static Integer myCar

Public Module go()
Display "I'm in method go."
End Module

End Class

Integer Plant :: myCar

Module main()

Declare Car myCar
Set myCar = new Car()
Call myCar.go()

End Module

4. In pseudocode write the first line of the definition for a Poodle class. The class should extend the Dog class.

Class Poodle Extends Dog

5. Look at the following pseudocode class definitions

Class Plant
Public Module message()
Display "I'm a plant."
End Module
End Class
Class Tree Extends Plant
Public Module message()
Display "I'm a tree."
End Module
End class

Given these class definitions, what will the following pseudocode display?

Declare Plant p
Set p = new Tree()
Call p.message()

The pseudocode will display "I'm a plant."

1. Pet Class

Design a class named Pet, which should have the following fields:

name-The name field holds the name of a pet.
type-The type field holds the type of animal that a pet is. Example values are "Dog","Cat", and "Bird"
age-The age field holds the pet's age.

The Pet class should also have the following methods:

setName-The setName method stores a value in the name field.

setType-The setType method stores a value in the type field.

setAge-The setAge method stores a value in the age field.

getName- The getName method returns the value of the name field

gettype- The getType method returns the value of the type field

getAge-The getAge method returns the value of the age field.

Once you have deigned the class, design a program that creates an object of the class and prompts the user to enter the name, type and age of his or her pet. This data should be stored in the object. Use the objects accessor methods to retrieve the pet's name, type, and age and display this data on the screen

Class Pet

Private String name
Private String type
Private Integer age

Public Module setName ()
Display "Enter Name: "
End Module

Public Module setType ()
Display "Enter Type: "
End Module

Public Module setAge ()
Display "Enter Age: "
End Module

Public Module getName ()
return name
End Module

Public Module getType ()
return type
End Module

Public Module getAge ()
return age
End Module

End class

Module main()

String n
String t
Integer a

Declare Pet obj

obj. setName ()
obj. setType ()
obj. setAge ()

n= obj. getName ()
t= obj. getType ()
a= obj. getAge ()

Display "Name: " n
Display "Type: " t
Display "Age: " a

End Module

Personal Information Class

Design a class that holds the following personal data:; name, address, age, and phone number. Write appropriate accessor and mutator methods. Also design a program that creates three instances of the class. One instance should hold your information and the other two should hold your firends or family members information

Class Personal_Information

Private String name
Private Integer age
Private Integer phone

Public Module setName ()
Display "Enter Name: "
End Module

End Module

Public Module setAge ()
Display "Enter Age: "
End Module

Public Module setPhone ()
Display "Enter Phone: "
End Module

Public Module getName ()
Display "Name: " name
End Module

End Module

Public Module getAge ()
Display "Age: " age
End Module

Public Module getPhone ()
Display "Phone: " phone
End Module

End class

Module main()

Declare Personal_Information personal

Display “Enter Personal Details”

personal. setName ()
persoanal. setAge ()
persoanal. setPhone ()

Display “Enter Friends’ Details”

Declare Personal_Information friends

friends. setName ()
friends. setAge ()
friends. setPhone ()

Display “Enter Family Details”

Declare Personal_Information family

family. setName ()
family. setAge ()
family. setPhone ()

Display “Personal Details”

personal. getName ()
personal. getAge ()
personal. getPhone ()

Display “Friends’ Details”

friends. getName ()
friends. getAge ()
friends. getPhone ()

Display “Family Details”

family. getName ()