Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 408 Weeks Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Management Posted 07 Jun 2017 My Price 15.00

solutions to my coursework written in Java Language

I would like my solutions to my coursework written in Java Language. They need to be written in Java Language & Java Code. Cheers. When you have completed the Assignment Solutions, please clearly identify, label & attach each completed file separately, as you did before. Cheers.

Document Preview:
 

G51OOP unit 2 exercise travel3: Travel times (weight 4%) ======================================================== Introduction ============ To make the program more realistic, the journey undertaken will now involve several different road types. Problem specification ===================== You are to write a program to repeatedly read a single character representing the type of road and a distance in kilometres (as a "double") and compute and print the time in seconds and in hours, minutes and seconds that it would take to travel that distance where the speed depends on the type of road as follows: type m (motorway) 85 kph type a (A road) 70 kph type b (B road) 55 kph type u (urban) 40 kph Other characters are invalid. You need to then prompt the user as to whether there is another leg of the journey. Method ====== Declare the speeds as constants. Read the road type, and use a "switch" statement (NOT "IF" statements on this occasion) to set the actual speed accordingly. If an invalid road type is entered you are to print the error message: Invalid road type X where X is the invalid character and use System.exit( -1 ) in order to force your program to terminate, do not attempt to read the distance. If the type is valid, read the distance as a "double" value, and convert it to seconds of travel using the formula time = distance / speed if the user enters a value for the distance which is less than or equal to zero you are to print the following error message: Illegal Distance Value and start again by prompting for a new road type. You are to print the results for each road type in the previous travel exercisek and as shown below eg. To travel 1234.0 road type m takes 52263 seconds To travel 1234.0 road type m takes 14 hours 31 minutes 3 seconds Once printed you are to prompt the user: Another Road (y/n): If the user enters a 'y' or...G51OOP u2 - Debugging: (Weight: 2) 

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

 

Introduction

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

 

This is the first problem you will receive where you 

are to debug a program that has already been written. 

 

The program may look complicated but is in fact fairly easy

and already written for you, you just need to read it carefully

to spot the glaring errors.  

 

NOTE

====

 

Coursemarker does not like Eclipse's default indentation style 

for switch statements. Coursemarker insists that case statements

are indented within the switch body, whereas Eclipse leaves them

flush in line with the switch.

 

Either manually indent everything by highlighting it and pressing tab

OR

Edit Eclipse's code formatter settings (google this or ask a preceptor)

 

 

Problem specification

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

 

You are to fix a program that imitates everyone's favourite

Harry Potter author JK Rowling.  The program should first print

a menu stating the following:

 

G51OOP's JK Rowling Impersonator

 

a) Count My Money

b) Title of the next book

q) Quit

 

Make a Choice (a/b/q):

 

At which point you are to read the character the user has entered.

This character corresponds to the menu option required.  If the user

enters 'a' (or 'A' - capitals are also allowed) then the program should prompt

the user with:

 

Enter a number:

 

At which point you are to read an integer from the user. This number should be

greater than or equal to 1000; if it is not then you are to throw an error (see error 

conditions below).  If it is greater than or equal to 1000, then the program should 

then perform the following calculation:

 

Multiply the number by 27 then divide by 8 and then add 9

 

You are then to print the statement:

 

I have XXX pounds

 

Where XXX is the answer calculated.

 

If the user enters b or B you are to print the title of the next

book in the series:

 

Harry Potter goes to the dentist

 

If the user enters q or Q you are to print:

 

Time to turn people into Toads

 

and exit the program.

 

If the user enters anything else then you are to print:

 

Illegal value entered into menu

 

and exit the program with the value -1.

 

Method 

======

 

You are to use all debugging methods available to you to try and

find the collection of logical and compilation errors.  Your lab

demonstrator is able to assist you in the explanation of the debugging

methods but not how to solve the problem itself.    

 

Notes

=====

 

Both upper and lower case is allowed for the selection of menu

options. 

 

You have three (3) submissions.

 

Error conditions

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

 

If when reading in an int from the user they enter a value that is 

not greater than or equal to 1000, then you are to print:

 

I have more money than that!

 

and not perform the calculation at all.    

 

If the user enters anything that it not a, A, b, B, q, or Q then

you should print the following:

 

Illegal value entered into menu

 

and exit the program with the value -1.

 

Mark scheme

===========

 

60% : Dynamic correctness

10% : Typographic quality

30% : Program features

 

Typical input 

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

 

G51OOP's JK Rowling Impersonator

 

a) Count My Money

b) Title of the next book

q) Quit

 

Make a Choice (a/b/q): a

Enter a number: 1001

 

Corresponding output 

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

 

I have 3387 pounds

G51OOP u2 exercise Debug2: (Weight: 4%) 

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

 

Introduction

=========

 

Again you have another semi complete exercise to debug.

However this time with the introduction of loops, make 

sure that you test your program properly.

 

If CourseMarker seems to have frozen and you can't access

the screen, it has *NOT* crashed, it is just waiting for 

your program to time out due to an infinite loop you've

got yourself stuck in.  Do NOT quit the program, wait 

until control returns a few minutes later otherwise you

may well encounter some unexpected results.

 

Best still is to test your program FIRST, thoroughly before submitting

it to CourseMarker.

 

Problem specification

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

 

You are to write a program that helps you perform basic maths

tasks, working out factorials, powers and primes.  Start by

printing the menu

 

Welcome to the G51OOP Maths Helper

 

Pick the problem you want help with.

 

a) factorial

b) powers

c) prime number

q) Quit

 

Your choice: 

 

and read in their choice as a character.

 

If the user selects a, you are to prompt the user for a number

 

Enter the factorial:

 

this is the factorial you are to work out.  You obtain the 

factorial value by multiplying every number between 1 and X

together, e.g.

 

factorial of 4 is 1 * 2 * 3 * 4

 

when you should print the answer in the form

 

The factorial of X is Y

 

if the user selects b, you are to prompt the user for 2 numbers,

the value and the power to raise it to

 

Enter the value: 

Enter the power: 

 

So 2 to the power of three, or 2 cubed is

 

2 * 2 * 2

 

and then print the answer in the form

 

a to the power of b is c

 

If the user enters c you are to prompt them to enter a number

 

Enter a number to prime check:

 

and then test to see if is a prime, prime numbers are those which

are only divisible by 1 and themselves

 

e.g. 3, 5, 7, 11, 13

 

you are then to print

 

x is prime

 

or

 

x is not prime

 

depending on the calculation results.

 

If the user enters q you are to quit the program.

 

Method 

======

 

You are to use all debugging methods available to you to try and

find the collection of logical and compilation errors.  Your lab

demonstrator is able to assist you in the explanation of the debugging

methods but not how to solve the problem itself.    

 

Notes

=====

 

Both upper and lower case is allowed for the selection of menu

options. 

 

Please note that the factorial and power values will get very big very

quickly so when you are testing your solution you may find it better

to use small values.

 

You have three (3) submissions.

 

Error conditions

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

 

The users should be allowed both upper and lower case for

the menu choices.  However any other option that has not 

already been mentioned should be counted as an error and 

print the message 

 

Illegal menu option

 

then return to the main menu and start again.

 

When creating the powers both the value and the power, in

our example should be positive and greater than zero.  If 

not print the message

 

Illegal number value

 

or

 

Illegal power value

 

If users enters an Illegal number value, then you should not prompt for the power value.

 

You can assume all other values will be correct.  

 

Mark scheme

===========

 

70% : Dynamic correctness

10% : Typographic quality

20% : Program features

 

Typical input / output 

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

 

Welcome to the G51OOP Maths Helper

 

Pick the problem you want help with.

 

a) factorial

b) powers

c) prime number

q) Quit

 

Your choice: a

 

Enter the factorial: 4

 

The factorial of 4 is 24

 

Welcome to the G51OOP Maths Helper

 

Pick the problem you want help with.

 

a) factorial

b) powers

c) prime number

q) Quit

 

Your choice: q

 

Quitting

G51OOP u2 exercise Debug2: (Weight: 4%) 

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

 

Introduction

=========

 

Again you have another semi complete exercise to debug.

However this time with the introduction of loops, make 

sure that you test your program properly.

 

If CourseMarker seems to have frozen and you can't access

the screen, it has *NOT* crashed, it is just waiting for 

your program to time out due to an infinite loop you've

got yourself stuck in.  Do NOT quit the program, wait 

until control returns a few minutes later otherwise you

may well encounter some unexpected results.

 

Best still is to test your program FIRST, thoroughly before submitting

it to CourseMarker.

 

Problem specification

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

 

You are to write a program that helps you perform basic maths

tasks, working out factorials, powers and primes.  Start by

printing the menu

 

Welcome to the G51OOP Maths Helper

 

Pick the problem you want help with.

 

a) factorial

b) powers

c) prime number

q) Quit

 

Your choice: 

 

and read in their choice as a character.

 

If the user selects a, you are to prompt the user for a number

 

Enter the factorial:

 

this is the factorial you are to work out.  You obtain the 

factorial value by multiplying every number between 1 and X

together, e.g.

 

factorial of 4 is 1 * 2 * 3 * 4

 

when you should print the answer in the form

 

The factorial of X is Y

 

if the user selects b, you are to prompt the user for 2 numbers,

the value and the power to raise it to

 

Enter the value: 

Enter the power: 

 

So 2 to the power of three, or 2 cubed is

 

2 * 2 * 2

 

and then print the answer in the form

 

a to the power of b is c

 

If the user enters c you are to prompt them to enter a number

 

Enter a number to prime check:

 

and then test to see if is a prime, prime numbers are those which

are only divisible by 1 and themselves

 

e.g. 3, 5, 7, 11, 13

 

you are then to print

 

x is prime

 

or

 

x is not prime

 

depending on the calculation results.

 

If the user enters q you are to quit the program.

 

Method 

======

 

You are to use all debugging methods available to you to try and

find the collection of logical and compilation errors.  Your lab

demonstrator is able to assist you in the explanation of the debugging

methods but not how to solve the problem itself.    

 

Notes

=====

 

Both upper and lower case is allowed for the selection of menu

options. 

 

Please note that the factorial and power values will get very big very

quickly so when you are testing your solution you may find it better

to use small values.

 

You have three (3) submissions.

 

Error conditions

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

 

The users should be allowed both upper and lower case for

the menu choices.  However any other option that has not 

already been mentioned should be counted as an error and 

print the message 

 

Illegal menu option

 

then return to the main menu and start again.

 

When creating the powers both the value and the power, in

our example should be positive and greater than zero.  If 

not print the message

 

Illegal number value

 

or

 

Illegal power value

 

If users enters an Illegal number value, then you should not prompt for the power value.

 

You can assume all other values will be correct.  

 

Mark scheme

===========

 

70% : Dynamic correctness

10% : Typographic quality

20% : Program features

 

Typical input / output 

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

 

Welcome to the G51OOP Maths Helper

 

Pick the problem you want help with.

 

a) factorial

b) powers

c) prime number

q) Quit

 

Your choice: a

 

Enter the factorial: 4

 

The factorial of 4 is 24

 

Welcome to the G51OOP Maths Helper

 

Pick the problem you want help with.

 

a) factorial

b) powers

c) prime number

q) Quit

 

Your choice: q

 

Quitting

G51OOP unit 2 exercise travel3: Travel times (weight 4%)

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

 

Introduction

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

 

To make the program more realistic, the journey undertaken will now involve

several different road types.

 

Problem specification

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

 

You are to write a program to repeatedly read

 

a single character representing the type of road and

a distance in kilometres (as a "double")

 

and compute and print the time in seconds and in hours, minutes and seconds that

it would take to travel that distance where the speed depends on the type of road

as follows:

 

type m (motorway) 85 kph

type a (A road)         70 kph

type b (B road)         55 kph

type u (urban)          40 kph

 

Other characters are invalid.  You need to then prompt the user as to whether there 

is another leg of the journey.  

 

Method 

======

 

Declare the speeds as constants. 

 

Read the road type, and use a "switch" statement (NOT "IF" statements on this occasion)

to set the actual speed accordingly. If an invalid road type is entered

you are to print the error message:

 

Invalid road type X

 

where X is the invalid character and use System.exit( -1 ) in order 

to force your program to terminate, do not attempt to read the distance.

 

If the type is valid, read the distance as a "double" value, and convert it to seconds of travel 

using the formula

 

time = distance / speed

 

if the user enters a value for the distance which is less than or equal

to zero you are to print the following error message:

 

Illegal Distance Value

 

and start again by prompting for a new road type.  

 

You are to print the results for each road type in the previous travel exercisek and as shown 

below eg. 

 

To travel 1234.0 road type m takes 52263 seconds

To travel 1234.0 road type m takes 14 hours 31 minutes 3 seconds

 

Once printed you are to prompt the user:

 

Another Road (y/n):

 

If the user enters a 'y' or 'Y' you are to ask the user to enter details

for the next stage of their journey.  

 

When the user's journey has been completely entered you are to print

the total distance travelled and total time taken in seconds

 

To complete your journey of xxx km takes yyy seconds

 

and then quit.  

 

Hints 

=====

 

Be careful of units! If distance is in kilometres and speed is in kilometres 

per hour, the above formula gives the result in hours!

 

There should only be ONE "if" statement in your program!

 

Choose your loop type carefully.

 

Notes

=====

 

You have three (3) submissions.

 

Error conditions

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

 

If the road type is not one of the given 4 characters (but do allow capitals i.e. 4 * 2), print the message

 

Invalid road type x

 

where "x" is the invalid character and

also use System.exit( -1 ) in order to force your program to terminate before

it reads a distance value.

 

If the distance is not greater than zero you are to print the message

 

Illegal Distance Value

 

and ask the user for a new road type.  

 

Mark scheme

===========

 

80% : Dynamic correctness

10% : Typographic tests

10% : Feature tests

 

Typical input/output 

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

 

Type the road type:  m

Type the travel distance:  1234

 

To travel 1234.0 takes 52263 seconds

To travel 1234.0 road type m takes 14 hours 31 minutes 3 seconds

 

Another Road (y/n):  y

 

Type the road type:  a

Type the travel distance:  15

 

To travel 15.0 takes 771 seconds

To travel 15.0 road type a takes 0 hours 12 minutes 51 seconds

 

Another Road (y/n):  n

 

To complete your journey of 1249.0 km takes 53034 seconds

 

G51OOP unit 2 exercise travel3: Travel times (weight 4%)

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

 

Introduction

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

 

To make the program more realistic, the journey undertaken will now involve

several different road types.

 

Problem specification

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

 

You are to write a program to repeatedly read

 

a single character representing the type of road and

a distance in kilometres (as a "double")

 

and compute and print the time in seconds and in hours, minutes and seconds that

it would take to travel that distance where the speed depends on the type of road

as follows:

 

type m (motorway) 85 kph

type a (A road)         70 kph

type b (B road)         55 kph

type u (urban)          40 kph

 

Other characters are invalid.  You need to then prompt the user as to whether there 

is another leg of the journey.  

 

Method 

======

 

Declare the speeds as constants. 

 

Read the road type, and use a "switch" statement (NOT "IF" statements on this occasion)

to set the actual speed accordingly. If an invalid road type is entered

you are to print the error message:

 

Invalid road type X

 

where X is the invalid character and use System.exit( -1 ) in order 

to force your program to terminate, do not attempt to read the distance.

 

If the type is valid, read the distance as a "double" value, and convert it to seconds of travel 

using the formula

 

time = distance / speed

 

if the user enters a value for the distance which is less than or equal

to zero you are to print the following error message:

 

Illegal Distance Value

 

and start again by prompting for a new road type.  

 

You are to print the results for each road type in the previous travel exercisek and as shown 

below eg. 

 

To travel 1234.0 road type m takes 52263 seconds

To travel 1234.0 road type m takes 14 hours 31 minutes 3 seconds

 

Once printed you are to prompt the user:

 

Another Road (y/n):

 

If the user enters a 'y' or 'Y' you are to ask the user to enter details

for the next stage of their journey.  

 

When the user's journey has been completely entered you are to print

the total distance travelled and total time taken in seconds

 

To complete your journey of xxx km takes yyy seconds

 

and then quit.  

 

Hints 

=====

 

Be careful of units! If distance is in kilometres and speed is in kilometres 

per hour, the above formula gives the result in hours!

 

There should only be ONE "if" statement in your program!

 

Choose your loop type carefully.

 

Notes

=====

 

You have three (3) submissions.

 

Error conditions

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

 

If the road type is not one of the given 4 characters (but do allow capitals i.e. 4 * 2), print the message

 

Invalid road type x

 

where "x" is the invalid character and

also use System.exit( -1 ) in order to force your program to terminate before

it reads a distance value.

 

If the distance is not greater than zero you are to print the message

 

Illegal Distance Value

 

and ask the user for a new road type.  

 

Mark scheme

===========

 

80% : Dynamic correctness

10% : Typographic tests

10% : Feature tests

 

Typical input/output 

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

 

Type the road type:  m

Type the travel distance:  1234

 

To travel 1234.0 takes 52263 seconds

To travel 1234.0 road type m takes 14 hours 31 minutes 3 seconds

 

Another Road (y/n):  y

 

Type the road type:  a

Type the travel distance:  15

 

To travel 15.0 takes 771 seconds

To travel 15.0 road type a takes 0 hours 12 minutes 51 seconds

 

Another Road (y/n):  n

 

To complete your journey of 1249.0 km takes 53034 seconds

 

 

Answers

(5)
Status NEW Posted 07 Jun 2017 10:06 PM My Price 15.00

Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â-----------  -----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------. P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)