2. Correct the errors in this Java program, which is intended to find the area of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. Correct the errors in this Java program, which is intended to find the area of a triangle, given its base and height, using the formula half the base times height: import java.util.Scanner; public class Area { } public static void Main(String[] args) { input new Scanner (System.in); System.out.print("Enter base: ); double base input.nextInt (); System.out.print("Enter height: "); double height = input.nextDouble(); double area = 1/2* base system.out.println("The area is " + area); input.close(); height 2. Correct the errors in this Java program, which is intended to find the area of a triangle, given its base and height, using the formula half the base times height: import java.util.Scanner; public class Area { } public static void Main(String[] args) { input new Scanner (System.in); System.out.print("Enter base: ); double base input.nextInt (); System.out.print("Enter height: "); double height = input.nextDouble(); double area = 1/2* base system.out.println("The area is " + area); input.close(); height
Expert Answer:
Answer rating: 100% (QA)
The Java program shown in the image is intended to calculate the area of a triangle which is given b... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
Standard output 500 units actual output 400 units standard price rupees 2 per kg actual price rupees 3 per kg actual Quantity 2000 kg standard quantity 4 kg per unit Calculate material cost variance,...
-
How do you simplify the max method in the following, using the conditional operator? 1: /** Return the max of two numbers */ 2: public static int max ( int num1, int num2 ) { 3: int result; 4: 5: if...
-
How many types of B cells are produced in the process of clonal expansion? Summarize why each is needed for a thorough and long-lasting humoral immune response to an antigen.
-
The table lists the actual annual cost y to drive a midsize car 15,000 miles per year for selected years X. (a) Predict whether the correlation coefficient is positive, negative, or zero. (b) Find a...
-
Lorenzo-Netto, Srl, operates a brushless car wash. Incoming cars are put on an automatic, continuously moving conveyor belt. Cars are washed as the conveyor belt carries the car from the start...
-
A large negative charge Q is located in the vicinity of points A and B. Suppose a positive charge +q is moved at constant speed from A to B by an external agent. Along which of the paths shown in the...
-
Separation of duties refers to separating all of these functions except which of the following? a. Authorizing transactions b. Keeping accounting records C. Hiring personnel d. Maintaining custody of...
-
Refer to the financial statements of American Eagle (Appendix B) and Urban Outfitters (Appendix C). Required: 1. A few years ago, American Eagle Outfitters split its stock. Describe the impact that...
-
Prepare and Evaluate Budgeted Income Statement Fairfield Stores, a retailer in a shopping mall, prepared the following income statement for its operations for the month just ended: Sales FAIRFIELD...
-
On December 31, 2021, the end of its first year of operations, Botani Associates owned the following securities that are held as long-term investments. On this date, the total fair value of the...
-
Using the following year-end information for Work-Fit calculate the acid-test ratio: Cash Short-term investments Accounts receivable (all current) Inventory Supplies Accounts payable Wages payable $...
-
A stock has just payed its annual dividend at $1.1/share. The dividend payments are expected to stay at the current growth path of 1.3% per year indefinitely. Investors require a return of 7.1% for...
-
You are considering to deposit $1200 into a 8.9% savings account every year over the next 13 years. Alternatively, you can just deposit one larger sum of money in the account today, and no additional...
-
Your sister has found an attractive savings account overseas. She is planning to put $15,263 in that account today. The account pays an interest of 5%, compounding monthly. How much will there be in...
-
Eppich Corporation has provided the following data for the most recent month: Raw materials, beginning balance Work in process, beginning balance Finished Goods, beginning balance Transactions: (1)...
-
How long will it take for a $2000 investment to grow to $3500 at an annual rate of 8.5%,compounded quarterly? Assume that no withdrawals are made. Do not round any intermediate computations, and...
-
Water rises in a capillary tube to a height of 2.0cm. How much will the water rise through another capillary tube whose radius is one-third of the first tube?
-
Southwestern Punch was made by Frutayuda, Inc. and sold in 12-ounce cans to benefit victims of Hurricane Zero. The mean number of ounces placed in a can by an automatic fill pump is 11.7 with a...
-
Programming Exercise 15.30 developed a slide show using images. Rewrite that program to develop a slide show using text files. Suppose ten text files named slide0.txt, slide1.txt, . . . , and...
-
Write a program that compresses a source file into a target file using the Huffman coding method. First use ObjectOutputStream to output the Huffman codes into the target file, and then use...
-
Write a program that reads in investment amount, annual interest rate, and number of years, and displays the future investment value using the following formula: futureInvestmentValue =...
-
In order to have a correlation coefficient between traits A and B, it is necessary to have: a. one group of subjects, some of whom possess characteristics of trait A, the remainder possessing those...
-
What would you guess the value of the correlation coefficient to be for the pair of variables: "number of man-hours worked" and "number of units of work completed"? a. Approximately 0.9 b....
-
True or False: Whenever r is calculated on the basis of a sample, the value which we obtain for r is only an estimate of the true correlation coefficient which we would obtain if we calculated it for...
Study smarter with the SolutionInn App