Assignment 1 1. Write a program to implement the following formula for a -10 and b...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Assignment 1 1. Write a program to implement the following formula for a -10 and b = 4; result = (a + 2b - 4ab)^4 // ^4 means to the power of 4 (1 mark) 2. Write a program to implement result = sin (PI / 3) * tan (PI / Use the double data type. 4) (1 mark) 3. Write a program to count the sum of integers from 10 to 20. Use a for loop. (1 mark) 4. Do question 3 using a while loop. (1 mark) 5. Write a program to find the sum of all odd integers starting from 11 to 21, inclusive. Your program should count 11 +13 + 15 + (2 marks) + 21. 6. Do question 5 using even numbers from 10 to 20. (2 marks) 7. Find the volume of a cylinder with radius 2 and height of 4. Remember that V = PI rr height () (4 marks) 8. Imagine you work 8 hours from Monday to Thursday, 6 hours on Friday, 4 hours on Saturday, and you are off on Sunday. Write a program to accept the day index as an integer from the user and display the hours. In a while loop continuously ask the user and display the hours worked. Terminate the program when the user enters an index outside 0-6. Use a switch statement; do not use an if-else structure. Here is an example of how a user interacts with your program: Program: Please enter a day index. Use 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on. User : 2 Program: You work 8 hours on Tuesdays. Program: Please enter a day index. Use 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on. User : -1 Program: Program terminating. (8 marks) Assignment 1 1. Write a program to implement the following formula for a -10 and b = 4; result = (a + 2b - 4ab)^4 // ^4 means to the power of 4 (1 mark) 2. Write a program to implement result = sin (PI / 3) * tan (PI / Use the double data type. 4) (1 mark) 3. Write a program to count the sum of integers from 10 to 20. Use a for loop. (1 mark) 4. Do question 3 using a while loop. (1 mark) 5. Write a program to find the sum of all odd integers starting from 11 to 21, inclusive. Your program should count 11 +13 + 15 + (2 marks) + 21. 6. Do question 5 using even numbers from 10 to 20. (2 marks) 7. Find the volume of a cylinder with radius 2 and height of 4. Remember that V = PI rr height () (4 marks) 8. Imagine you work 8 hours from Monday to Thursday, 6 hours on Friday, 4 hours on Saturday, and you are off on Sunday. Write a program to accept the day index as an integer from the user and display the hours. In a while loop continuously ask the user and display the hours worked. Terminate the program when the user enters an index outside 0-6. Use a switch statement; do not use an if-else structure. Here is an example of how a user interacts with your program: Program: Please enter a day index. Use 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on. User : 2 Program: You work 8 hours on Tuesdays. Program: Please enter a day index. Use 0 for Sunday, 1 for Monday, 2 for Tuesday, and so on. User : -1 Program: Program terminating. (8 marks)
Expert Answer:
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date:
Students also viewed these programming questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
"internet radios" for streaming audio, and personal video recorders and players. Describe design and evaluation processes that could be used by a start-up company to improve the usability of such...
-
The following are some examples of typical business transactions: 1. Purchased office equipment on credit. 2. The owner contributed capital. 3. Purchased office furniture for cash. 4. Received...
-
The polarization of a carbonyl group can be represented by a pair of resonance structures: Cyclopropenone and cycloheptatrienone are more stable than anticipated. Cyclopentadienone, however, is...
-
Plaintiff Caruso was gambling at the Foxwoods Casino, which was owned by defendant Mashantucket Pequot Gaming Enterprise. When he went to use the restroom, Caruso noticed an attendant holding a mop...
-
Two of the three wires in Figure P28.8 carry current \(I\), and the third wire carries current 6I. The location labeled \(\mathrm{P}\) is a distance \(d\) from cach of the wires carrying current...
-
(Multiple Choice) 1. Which of the following costs are reported on a companys income statement and balance sheet? Income Statement Balance Sheet a. Accumulated depreciation .... Land b. Cost of goods...
-
15. A simple LR circuit is connected to a battery at t = 0. The time instant at which rate of energy storage in inductor is half of power delivered by battery (a) In 2 (c) In 2 (b) In () (d) In 3 16....
-
1 LE 2 -1 2 (a) w.v, (b) v.w, (c) v.wT (d) w.vT, (e) v.v, and (f) v.v. 2. Consider the vectors v = W = 0 1 3. Use the results from Call a v.v. Let I = = (a) Compute the matrix P = I - v.v. (b)...
-
Repeat Exercise E21.3, reading one line at a time and writing the reversed lines to a temporary file. Then erase the original and move the temporary file into its place. Data from exercise E21.3...
-
Provide a static method that returns the reverse of a generic array list, without modifying the original list.
-
Write a static generic method: that returns a list of pairs (v, f.apply(v)), where v ranges over the given values. List map (List values, Function f)
-
Give a SQL query that lists all products that have been purchased by a customer in California. Invoice Invoice_ Number INTEGER 11731 11732 11733 Customer_ Number INTEGER 3175 3176 3175 Payment...
-
Of the SQL commands introduced in this chapter, which yield result sets, which yield an update count, and which yield neither?
-
The level of small business involvement in Australia has an impact on employment rates. As a result data collected on small business informs a wide variety of policy decisions by government....
-
The Strahler Stream Order System ranks streams based on the number of tributaries that have merged. It is a top-down system where rivers of the first order are the headwaters (aka outermost...
-
Does the snowflake have rotational symmetry in Figure 1.6? If yes, describe the ways in which the flake can be rotated without changing its appearance. Does it have reflection symmetry? If yes,...
-
A couple in a sport-utility vehicle (SUV) is traveling at 90 km/h on a straight highway. The driver sees an accident in the distance and slows down to 40 km/h in
-
Which of the following statements are hypotheses? (a) Heavier objects fall to Earth faster than lighter ones. (b) The planet Mars is inhabited by invisible beings that are able to elude any type of...
Study smarter with the SolutionInn App