Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// Last month. Joe purchased some stock in Acme Software, Inc. Here are the // details of the purchase: // ' // The number of

image text in transcribedimage text in transcribedimage text in transcribed
image text in transcribedimage text in transcribedimage text in transcribed
// Last month. Joe purchased some stock in Acme Software, Inc. Here are the // details of the purchase: // ' // The number of shares that Joe purchaSed was 2,000. // When Joe purchased the stock, he paid $40.00 per share. // Joe paid his stockbroker a commission that amounted to 3 percent of the amount he paid for the stock. // ' // Two weeks later, Joe sold the stock. Here are the details of the sale: // . // The number of shares that Joe sold was 2,000. // He sold the stock for $42.75 per share. // He paid his stockbroker another commission that amounted to 3 percent of the amount he received for the stock. // // Write a program that calls a single function that calculates the value of a // stock purchased or sold, less the commission that was paid and calls this // function twice to calculate the profits Joe made from these transactions // function shareValueinumbeerShares. pricePerShare, commissionPercentage) { l/////////////////////////////////////////////////////////////////////////////// // Insert your code between here and the next comment block. Do not alter // // any code in any other part of this file. // ///////////////////////////////////////l///////////////////////////////////////// let costOfShares = g g pricePerShare: let commissionPaid = costOfShares * 9; return Q - Q; ///////////////l///////////////////////////////////////////////////////////////// // Insert your code between here and the previous comment block. Do not alter // // any code in any other part of this file. // //////////////////////////l////////////////////////////////////////////////////// ) let valueOfStocksPurchased = shareValue(2000, 40.0, .03): let valueOfStocksSold = shareValue2000, 42.75, .03); let profitsFromSale = valueOfStocksSold - valueOfStocksPurchased; alertt'After buying and selling 2,000 shares of stock, Joe has made $' + profitsFromSale);

// The date June 10, 1960, is special because when it is Written in the following // format, the month times the day equals the year: // . // 6/10/60 // // Design a program that asks the user to enter a month (in numeric form), a day, // and a year. The program should then call a function to determine // whether the month times the day equals the year. If the month times the day // equals the year then the function returns the boolean value true. If the month // times the day does not equal the year then the function returns the boolean value // false. // function magicDate(month. day, year) { ////////////////////////////////////////////////////////////////////////////////l // Insert your code between here and the next comment block. Do not alter // // any code in any other part of this file. // ////////////////////////////l//////////////////////////////////////////////////// let valueToReturn: if 19;) { I valueTbReturn = true; } else { me/VJ i valueTbReturn = false; 1 i return valueToReturn; 7//////////////////////////////////////////////////////////////////////////////// // Insert your code between here and the previous comment block. Do not alter // // any code in any other part of this file. // /////////////////////////l/////////////////////////////////////////////////////// } let mth = Parse!nt(prompt(\"Enter the month: "))3 let day = parse!nt(pronpt(\"Enter the day; u'); let year = parse!nt(prompt(\"Enter the year: ")); if (magicoate(month, day, year)! i ' alert('that is a magic date.'); } else { alertl'that is not a magic date.'); - ocean s eve is currently rising at about 1 6 mill' . . . . 1meters per // year. Write a function that is passed a number of years and then uses a loop ;; that calls the alert() function to display the total rise in ocean level for each // For example, if looking at the ocean level rise over 5 years the program would // display the following five alert with the values (don't worry about rounding and // formatting the output to look nice): // // Year 1.6 millimeters // Year 3.2 millimeters // Year 4.8 millimeters // Year - 6.4 millimeters // Year 8.0 millimeters // // When the loop ends the function will return the number of millimeters the ocean // has risen during this period. In this exampe, // function oceanRise(number0erars) { l//////////////////////////////////////////////////////////////////////////////// // Insert your code between here and the next comment block. Do not alter // // any code in any other part of this file. // /////////////////////////////I/////////////////////////////////////////////////// let totalRise = o; for (Q; { ' totalRise = totalRise + 1.6: alert('Year ' + year + ' ' + totalRise + ' millimeters'): 5 return totalRise; ///////////////////////////////////////////////////////////////////////////////// evious comment block. Do not alter // // Insert your code between here and the pr // // any code in any other part of this file. ///////////////////////////////////////////////////////I///////////////////////// } let numberOerars = prompt('0ver how many years would you like to display the rising in ocean levels? '); ' + oceanRise(number0erars) + ' millimeters'); . . n alert('In the next ' + numberOerars + ' years, the ocean will have rise Ln1,Col1 13b ,Iprr-hvv

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Retail Management A Strategic Approach

Authors: Barry Berman, Joel Evans, Patrali Chatterjee

13th Edition

0133796841, 9780133796841

More Books

Students also viewed these General Management questions