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
-
How does a healthcare organization ensure that they are meeting their regulatory obligations? Post your thoughts and respond to two classmates. PLEASE PROVIDE SOURCES
-
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...
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
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...
-
Explain why each compound or ion should be aromatic, antiaromatic, or nonaromatic. (a) The cyclonona-tetraene cation (b) The cyclononatetraene anion (c) The [16]annulene dianion (d) The [18]annulene...
-
A final settling tank for a 2 million gallon per day (2 MGD) activated sludge treatment plant has an average overflow rate of 800 gal/day-ft^2. The tank needs to have a minimum detention time of 2...
-
Task: Use Excel and the Solver add-in to explore the effect of various resource constraints on the optimal product mix. a. Read the article Boost Profits With Excel, by James A. Weisel in the...
-
1. What are some of the steps that led to creating eHarmony? 2. What advantages did eHarmony have because it was not the first entrant into the online dating market space? 3. What disadvantages might...
-
How would you use Hyper-V high availability and NLB for support in business continuity and disaster recovery efforts? Please list any references so I may look at them.How would you use Hyper-V high...
-
In receiving terminals of petrochemical plants, some of the liquid natural gas (LNG) storage Tanks are designed to be in ground, to avoid receiving radiation from the sun and also being protected...
-
A college offers help in Math, English, Chemistry, and Biology. The number of students enrolled in each subject is listed below. The college can only afford to hire 17 helpers. Using Lowndes's method...
-
We need something advanced. You know something that will help us solve a truly tough problem requiring "advanced decision-making." Do you remember studying the Amazon case where they faced a monster...
-
If I have run a coffee shop and have two entities - orders and menuItems, which is the strong entity and which is the weak entity and why. 2.What is an entity class vs an entity instance 3.What Makes...
-
Sofia, a salesperson, is on her client's company website and is studying about the company's work environment, corporate culture, and their short and long-term goals. In this context, Sofia is trying...
-
Can you kindly assist me with the below. I really appreciate your assitance. each wortth forrttyyy poiiinttss. Thank again for helping. Large IT departments have traditionally been the focus of...
-
In the figure shown below, all angles are right angles, and the side lengths given are in centimeters. What is the area, in square centimeters, of the figure? 6 9 13 3 3
-
A project that will provde annual cash flows of $2,600 for nine years costs $10,700 today. a. At a required return of 12 percent, what is the NPV of the project? Note: Do not round intermediate...
-
We all experience emotions, but some people disguise their true feelings better than others. Do you think this is a helpful or harmful thing to do? Under what conditions do you think it would be most...
-
Suppose that we wish to compute the inverse and log-determinant of the matrix \[ \mathbf{I}_{n}+\mathbf{U} \mathbf{U}^{\top} \] where \(\mathrm{U}\) is an \(n \times h\) matrix with \(h \ll n\). Show...
-
Suppose that in the stochastic gradient descent method we wish to repeatedly draw minibatches of size \(N\) from \(\tau_{n}\) where we assume that \(N \times m=n\) for some large integer...
-
Denote the pdf of the \(\mathscr{N}(\mathbf{0}, \boldsymbol{\Sigma})\) distribution by \(\varphi \Sigma(\cdot)\), and let \[ \mathscr{D}\left(\boldsymbol{\mu}_{0} \boldsymbol{\Sigma}_{0} \mid...
Study smarter with the SolutionInn App