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

  Is this an example of head or tail recursion

Referring to the code in Part 1, use the substitution model to illustrate what the result of calling (add1-iter '(1 2 3)) will be. Why is the list reversed ?

  Creating a program that writes to a data file

Creating a program that writes to a data file called Celtofarendfile.txt using the end of file structure. The program should create a conversion table of Celsius to Fahrenheit from 0 to 100 Celsius in increments of 5.

  Deck of cards programming class

Write a complete program using "ECLIPS" that implements the functionality of a deck of cards. In writing your program, use the provided DeckDriver and Card classes shown below. Write your own Deck class so that it works in conjunction with the two..

  Write a program that calculates a cars gas mileage

Write a program that calculates a car's gas mileage - The program should ask the user to enter the number of gallons of gas the car hold and the number of miles it can be driven on a full tank.

  Problem related to reading file and doing averege

First the program must read a text file (The user must be able to write the name of the text file) , the text file contains the following: the expenses the company is going to spend. Text file example: Keywords:, #best_project_ever, Expenses:, Equi..

  Write a main method to test your max method

Write a main() method to test your max method. It should input three values, call your max method, and then print the three values and returned max value as output, eg:

  Explain is there a downside to using prototypes

Is there a downside to utilizing prototypes? Prototypes can show to user the look and feel of application but frquently the more sophisticated tools (like data entry verification) have not been implemented.

  Program to calculate cost of purchase-requests from user

Program calculates cost of purchase, requests another item selection from user, and so on. User enters 0 from item menu to quit.

  Calculate the average rainfall for three months

Write a program that asks the user to enter five floating-point numbers. The program should create a file and save all five numbers to the file.

  Write a program to solve to find loan on tv

Write a program to solve follwoing problem: A TV set is bought with loan of $563 to be paid off with 5 monthly payments of $116. Interest rate is 1 percent per month.

  Create gui application that allows the user to enter the

A movie theater only keeps a percentage of the revenue earned from ticket sales. The remainder goes to the movie company. Create a GUI application that allows the user to enter the data into text fields.

  Develop a concentration game

Concentration, also known as Shinkei-suijaku, Memory, Pelmanism, Pexeso or simply Pairs, is a card game in which all of the cards are laid face down on a surface and two cards are flipped face up over each turn.

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