Program that creates a customised children''s story

Assignment Help Programming Languages
Reference no: EM13935662

Imagine you are writing a computer program that creates a customised children's story using names provided by the user of the program. Your first attempt at the program prompts the user for the gender and name of the hero, the type and name of their pet, and writes the first two sentences of the story.

For instance, if the user provides the following information: 'F' (for female), Poppy, cat, Jess, the program will produce the output given in Figure 4:

Note: Figure in the attached Question.pdf document

A skeleton version of the program which is to produce the output as shown in Figure 4 can be found in the file M150_TMA02_2011B_Q4(iii).html that you downloaded with this assignment. Open this file and save it as M150_TMA02_2011B_Q4(iii)_answer.html.

Look at the skeleton program and answer part (a) below. Then develop the program by editing your answer file step-by-step as specified in parts (b) to (e). (You may find it useful to look at Activity 2.10 in Unit 7 and its solution.) The first two lines of code have been written for you. The user is prompted for the hero's gender ('F' or 'M') and the hero's name. (Note the need for the escape character before the apostrophe in the prompt string.)

(a) What is the purpose of the second argument 'F' in the statement
heroGender = window.prompt('Is the hero female or male? Enter F or M', 'F'); ?

(b) Write the next two lines of code (as indicated by the comments in the code file) to prompt the user for the type of pet (i.e. what type of animal it is) and the name of the pet.

The program is not expected to check that what the user enters makes sense. It should simply accept whatever is input.

Run the program and check that it prompts for four inputs in total. (You can enter whatever you like in response to each prompt. The program will not yet produce any output.)

Take a screenshot of the prompt for the name of the pet and insert the screenshot into your Solution Document along with the two lines of code you have added.

(c) Write a line of code to output 'Once upon a time there was a ' (note the space at the end). Run the program and check that it now prompts for four inputs then writes this output. Insert this line of code in your Solution Document.

(d) You now need a selection structure to decide whether to output 'girl ' or 'boy '. Here is the required algorithm:

if heroGender is 'F'
output 'girl '
else
output 'boy '

Using this algorithm, write the code and test that it works. Insert the selection code in your Solution Document.

(e) Write the code to produce the remaining output, as in Figure 4. The second sentence should appear on a new line. Take a screenshot of the output from your final program. It should be similar to Figure 4, but with different details. Insert the screenshot and the code you have written for this part into your Solution Document.

Attachment:- Question.zip

Reference no: EM13935662

Questions Cloud

Compute the cost per equivalent unit for material : Compute the cost per equivalent unit for material and for conversion costs for May.
Will ventura benefit more from exchange rate effects : Will Ventura benefit more from exchange rate effects if its parent provides equity financing for the subsidiary or if the subsidiary is financed by local banks in Japan? Explain.
Hr management team for authentic profit-seeking organisation : For this assessment, you need to assume that your group is the HR management team for an authentic profit-seeking organisation. Task is to develop a new 12 month Strategic HR plan for the organisation.
Describe the structure of a multi-cellular fungus : Describe the structure of a multi-cellular fungus. Identify the vegetative and reproductive portions of the fungus. Distinguish between sexual and asexual fungal spores. Give examples of each type of spore.
Program that creates a customised children''s story : Imagine you are writing a computer program that creates a customised children's story using names provided by the user of the program.
Discriminate between employees purely on the basis of gender : In all areas of HR practice, including determining pay levels, it is unlawful for Australian employers to discriminate between employees purely on the basis of gender. However, in Australia, aselsewhere, the gender pay gap persists.
Beginning work in process and costs added in november : Reconcile the sum of the two costs in part b to the sum of beginning Work in Process and costs added in November
List the characteristics of the phylum chordata : Although amphibians were the first animals to move onto dry land, they were still dependent on water for reproduction and lor respiration. What evolutionary adaptations allowed reptiles to become the first "true" land vertebrates?
Common features of internet search engines : If you had this citation for an article. Paul, D. L. (1999). Assessing technological barriers to telemedicine: Technology-management implications. IEEE Transactions on Engineering Management, 46(3) 279-289. What would you search to see if the libra..

Reviews

Write a Review

Programming Languages Questions & Answers

  Write application to inputs ten numbers from user

Write the application to inputs ten numbers from user, each number can be between 10 and 100, inclusive. As each number is read in determine if it is number already entered.

  Program to track hourly employee arrival and departure times

A company hires you to write a program to track hourly employee arrival and departure times from work. In essence, you are tasked to make an online time clock

  Function to compute the average of numbers

Function will then compute the average of numbers, total of all of the numbers added together, and new array of numbers.

  Calculating hit ratio for program having loops

Calculate hit ratio for program that loops 10 times from locations 0 - 64.

  Design bank account class with data members-member functions

Design the Bank Account class with suitable data members and member functions - think of attributes or features of a bank account - think of kind of data (and actions) you require to open account.

  Write program that allow a user to enter stuin thident names

Write a program that would allow a user to enter stuIn thident names and Final grades (e.g. A,B,C,D,F) from their courses. You do not know how many students need to be entered.

  Design program to ask user to enter amount of purchase

Design a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax.

  Rectangle data class and an executable program to test

For this assignment you are to create a Rectangle data class and an executable program to test

  Write a program to compute the volume flow rate in cubic

write a program to calculate the volume flow rate in cubic feet per second of water flowing through a pipe of diameter

  Program instantiates four dates and allots invalid values

Demonstration program instantiates four Dates and purposely allots invalid values to some of arguments; class methods will correct invalid values.

  Write a program takes input from a user in the phone

Program takes input from a user in the phone of a phone number, 7 digits plus the hyphen. It then checks whether a user has entered Q to quit, if 0 or 555 are the begging sequence of inputs (if they are the program alerts the user to an error with..

  What will the exp days column contain

If expiration_date contains a value that's equivalent to November 2, 2008 and the SYSDATE function returns a value that's equivalent to December 17, 2008, what will the exp_days column contain when this code is executed

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd