1. Complete the following methods: a) public static double calculateArea (double radius) { // return area of a circle } b) public static double toCelcius (double fahrenheit) { // convert tempreture from Fahrenheit to Celcius
Q: Identify the error(s) of the following method header: public static double method1(int num1,…
A: In java function we the parameter should have type defined. But in above public static double…
Q: PART 2 Problem #2: [25 pts] Print Multiples a) Write a method printMultiples that takes two integers…
A: import java.util.Scanner; public class Main{ public static void printMultiplies(int x, int y){…
Q: Trigonometric method draw circle full java code program ask User (Xc,Yc,radius r) in main class?
A: java program to draw a circle: import java.util.ArrayList;import java.util.Scanner; import…
Q: public static boolean isPrime(int number) public static void printPrime(int x) - printPrime method…
A: Sample Output: 2 3 5 7 11 13 17 19 23 29 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73…
Q: The scope of a is the body of its method. O a. default O b. parameter O. class d. static
A: default :- It can be access only within the package. It cannot be accessed from outside the…
Q: Dry run the below programs and explain the reasons of output. If there is any error then correct…
A: Below is the given program:
Q: Questions are based on following code; the integer on each line indicates the line number that is…
A: Question 2: Arguments are actual values which are passed to variables defined in the method header…
Q: Question 1) Write a method that takes continuously a positive number from the user and then returns…
A: Here, Code instruction is given.
Q: 4.16 LAB: Driving cost-methods Write a method drivingCost() with input parameters milesPerGallon,…
A: #Code- import java.util.Scanner; public class LabProgram { public static double…
Q: Declare a method with three arguments all of the type int. The method should return the greatest of…
A: The program is written in java. Please find the program in below step.
Q: 5) Write a method which gets a value from the user and convert that value from Celsius to…
A: Please find the answer below
Q: Toll roads have different fees based on the time of day and on weekends. Write a method calcToll()…
A: First we will convert both the time intervals given (i.e. Weekdays and Weekends) into minutes only.…
Q: 2. Write a method that calculates the tax on a price. The price and tax percentage should be…
A: Hello student Greetings Hope you are doing great. As per our policy guidelines, in case of multiple…
Q: Predict the return type of the below method. public static _______ calculate(int a , double b) {…
A: The options “int”, “float”, and “boolean”, are not the correct answers as the given method doesn’t…
Q: Complete the Team class implementation. For the instance method get_win_percentage(), the formula…
A: class Team: def __init__(self): self.team_name = 'none' self.team_wins = 0…
Q: One lap around a standard high-school running track is exactly 0.25 miles. Write a program that…
A: Required: One lap around a standard high-school running track is exactly 0.25 miles. Write a…
Q: (Number of days in a year) Write a method that returns the number of days in a year using the…
A: public class Solution { public static boolean isLeayYear(int y) { // if leap year…
Q: 1.Using pseudocode, a method that will add two numbers, and return the sum to the calling function.…
A: The, code has given below:
Q: java Exercise 1: Write a program to do the following using the Math class: Ask a user to enter two…
A: We need to solve: Exercise 1:Write a program to do the following using the Math class: Ask a user to…
Q: Use "print" and "println" statements, but use method calls to reduce the number of repeated "print"…
A: public class Lab1b {public static void main (String[] args) { int numBottles; numBottles = 5;…
Q: 1. Write the following method that display the result of the following serie 1 1 R ==+=+.. + 3 5 1…
A: Program Description: To write the following method that displays the result of the given…
Q: 1. Write the following method that display the result of the following serie 1 1 R ==+=+..+ 3 5 1 2…
A: The Java program reads the value of n from the user. Then call the function with one parameter that…
Q: What is the return type of a method that does not return any value? a)int b)void c)float…
A: correct option: B
Q: Requests two double values from the user and stores them in local variables in main() - Create a…
A: Please find the answer below :
Q: Construct 2 methods: void Input() and void maxNum(). The input method should allow user to input 3…
A: Java program to implement void Input() and void maxNum(): import java.util.Scanner;public class…
Q: In Java, methods must include all of the following except? a) Local variable/s b) Global…
A: A method is a collection of statements that perform some specific task and return the result to the…
Q: Part I Write a method that rotates the triangle around the origin with given degree. Note: Be…
A: Java Program: import java.lang.Math;import java.util.Scanner;// Point classclass Point{ // data…
Q: List the name of this method and the name and type of its parameter:public void setCredits(int…
A: public void setCredits(int creditValue) { credits = creditValue;}
Q: T/F 5) If you call the following two methods with the same value of x, they would both return the…
A: Suppose x = 2 If method1(2) is called then it will return 0+1+1=2. On the other hand, if method2(2)…
Q: Given class Triangle, complete the program to read and set the base and height of triangle1 and…
A: Answer in step2
Q: c# Now, modify the program so that the major functions appear in the following individual methods:…
A: modify the program so that the major functions appear in the following individual methods: GetMonth…
Q: T/F 2) The following method lacks a base case. public int noBaseCase(int x) { if(x > 0) return…
A: Given that, The following method lacks a base case.public int noBaseCase(int x){if(x > 0)return…
Q: 6.27 LAB: Toll calculation Use Java programming. Toll roads have different fees based on the time of…
A: public class Calculationoftoll { public double toll_calculate(int hour, boolean isMorning,…
Q: This program inputs the names of 5 students and the (integer) grades they earned in 3 tests. It then…
A: The program will need five methods as follows: Method names() will input the names and return the…
Q: construct 2 methods: Void input() and void maxNum(). The input method should allow user to input 3…
A: if statement evaluates whether an expression is true or false.
Q: java-Find the area of circle using method... Write an application that prompts the user for the…
A: import java.util.*;public class Main { public static double circleArea(double r){ return…
Q: 3. write a method which calculate the Earns as following: If the Job is Teaching assistance : Earns…
A: Required: C# program to calculate earning and print the results. All code and screenshots have…
Q: 1. Write a java program that calculate the GPA for 20 students. a. You will enter the grade for each…
A: The below program calculates the GPA of a student based on the Grade entered by user for three…
Q: Create a method that will compute the PI, if pi is 3.14. Given formula is : value = pi x square of…
A: In your question the acceleration value is given as 9.80 and asked to create a method to compute…
Q: Write a method that returns the lcm (least common multiple) of an unspecified number of integers.…
A: LCM: LCM stands for least common multiple. For example- The lcm of 4 and 6 is the least common…
Q: You can declare a void method as follow; public void int calculateSalary() { int num1=89; int…
A: WE have to find weather the syntax is correct or not.
Q: 1)What is the return type of a method that does not return any value? a) int b) float c) void d)…
A: 1. Answer: c Explanation: The function that does not return any value is termed as the void…
Q: Trigonometric method draw circle full code program ask User (Xc,Yc,radius r) in main class
A: Trigonometric method draw circle full code program ask User (Xc,Yc,radius r) in main class Since…
Q: Write a program to calculate area of circle. The main method should pass the radius of the circle to…
A: Algorithm : calculateArea function : Step 1 : declare variable. Step 2 : find the area using…
Q: T/F 2) There is no base case in the following method. public int noBaseCase(int x) { if(x > 0)…
A: Given that, There is no base case in the following method. public int noBaseCase(int x){if(x >…
Q: Program to compute interest = p * r * t, where p = $10K, rate = 6%, t = 10 years; these values are…
A: public class DisplayInterest { public static void main(String[] args) { double p = 10000, r = 0.06,…
Q: Write a program in java Write a program that asks the user to enter five test scores. The program…
A: Program Approach: Importing the necessary package Creating the main class Declaring the main method…
Q: 7. Complete the code: public class Test public static void main(String [] args) int i = 4; int j =…
A: According to the Question below the Solution:
Q: *6.7 (Financial application: compute the future investment value) Write a method that computes…
A: Solution :: 6.7 ) The following is the modfied program. you did not call the function…
Q: Q1/ By using class constrictor and destructor write a program to calculate Circumference and area of…
A: As programming language is not mentioned in the question so i attempted this question in c++
Complete the following methods
Step by step
Solved in 2 steps
- 1 public static int sum(int x, int y){ 2 int z = x +y; 3 return z; 4 } 5 public static void main(String[] args){ 6 … 7 sum(a+2, b); 8 … 9 } write the signature of the method sum: sum(int,int) *Method name/parameter list list local variables of sum: x, y, and y are local variables of the function. list the parameters of sum: int x, int y write the line number where a call to sum occurs 7 list the arguments for the above call list the return type of sum here ______________Find the error of the following method definition: public static void timesTwo( int x, int y) { int sum=x + y; return sum; }java Exercise 1:Write a program to do the following using the Math class: Ask a user to enter two integer numbersFinds the square root of each numberFinds the minimumFinds the maximum. Exercise 2:Write a program to calculate area of circle. The main method should pass the radius of the circle to a static method named calculateArea(). The program should display the calculated area inside the main method.
- Examine the following method header; then write an example call to the method. private void ResetValue(ref int value)Question:Write the method in java for following a)Method returns a translated pointb) Method returns a rotated point w.r.t pivot pointc) Method receives a Target point, Pivot point, Translation Factors and Angle in Degree, and it return a Point which is translated and rotated (Sequence is T->R). Must use methods of a and b.Given class Triangle, complete the program to read and set the base and height of triangle1 and triangle2, determine which triangle's area is larger, and output the larger triangle's info, making use of Triangle's relevant methods. class Triangle: def __init__(self):self.base = 0self.height = 0 def set_base(self, user_base):self.base = user_base def set_height(self, user_height):self.height = user_heightdef get_area(self):area = 0.5 * self.base * self.heightreturn areadef print_info(self):print('Base: {:.2f}'.format(self.base))print('Height: {:.2f}'.format(self.height))print('Area: {:.2f}'.format(self.get_area())) if __name__ == "__main__":triangle1 = Triangle()triangle2 = Triangle() # TODO: Read and set base and height for triangle1 (use set_base() and set_height())# TODO: Read and set base and height for triangle2 (use set_base() and set_height())# TODO: Determine larger triangle (use get_area())print('Triangle with larger area:')# TODO: Output larger triangle's info (use…
- 10.19 LAB: Winning team (classes) Complete the Team class implementation. For the instance method get_win_percentage(), the formula is:team_wins / (team_wins + team_losses) Note: Use floating-point division. Ex: If the input is: Ravens 13 3 where Ravens is the team's name, 13 is the number of team wins, and 3 is the number of team losses, the output is: Congratulations, Team Ravens has a winning average! If the input is Angels 80 82, the output is: Team Angels has a losing average. Use Python.Program to compute interest = p * r * t, where p = $10K, rate = 6%, t = 10 years; these values are to be passed from main() Besides main() the program has two methods: one that computes the interest and on that rounds interest to two decimal places public class DisplayInterest public static void main(String[] args) call a method that will do the computation with values for the above variables; with the exception of year, they are double main() displays computed interest after rounding computation method() rounding method() Note:- Please type and execute this java program and also need an output for this java program.Make sure each program has at least one method in addition to its driver method(main). Or use one driver main method and write method(s) for each of the program. It is a single program not two individual questions so please write both. Write a java program to compute each of the following, use a separate method for each. (i) Calculate the energy of a flight traveling at the speed of light, use e = mc2 take c as the speed (3*108), e = energy and m is mass of the flight. Prompt the user to enter the mass. (ii) Calculate the size of the gravitational force acting between you and your friend as you approach each other (center-to-center 1 meter apart) in the hall way. Use the formula below. Prompt the user to supply the values of M and m. ? = (?∗?∗m)/d2M = Mass of your friend m = Your mass d = center-to-center distance 1m G = 6.67 * 10 -11
- c# Now, modify the program so that the major functions appear in the following individual methods: GetMonth - This method prompts for and returns the month GetNumMurals - This method prompts for and returns the number of murals scheduled and is called twice -- once for interior murals and once for exterior murals ComputeRevenue - This method accepts the number of interior and exterior murals scheduled, accepts the month they are scheduled, displays the interior and exterior prices, and then returns the total expected revenue DataEntry - This method fills an array with customer names and mural codes and is called twice -- once to fill the array of interior murals and once to fill the array of exterior murals GetSelectedMurals - This method continuously prompts for mural codes and displays jobs of the corresponding type until a sentinel value is entered using systeml using static System.Console; using System.Globalization; class MarshallsRevenue { staticvoidMain() { // Your code here…6.27 LAB: Toll calculation Use Java programming. Toll roads have different fees based on the time of day and on weekends. Write a method calcToll() that has three parameters: the current hour of time (int), whether the time is morning (boolean), and whether the day is a weekend (boolean). The method returns the correct toll fee (double), based on the chart below. Weekday Tolls Before 7:00 am ($1.15) 7:00 am to 9:59 am ($2.95) 10:00 am to 2:59 pm ($1.90) 3:00 pm to 7:59 pm ($3.95) Starting 8:00 pm ($1.40) Weekend Tolls Before 7:00 am ($1.05) 7:00 am to 7:59 pm ($2.15) Starting 8:00 pm ($1.10) Ex: The method calls below, with the given arguments, will return the following toll fees: calcToll(8, true, false) returns 2.95calcToll(1, false, false) returns 1.90calcToll(3, false, true) returns 2.15calcToll(5, true, true) returns 1.05 public class LabProgram {public static double calcToll(int hour, boolean isMorning, boolean isWeekend) {/* Type your code here. */ } public static void…Write a method that returns the lcm (least common multiple) of an unspecified number of integers. The method header is specified as follows: public static int lcm(int... numbers) Write a test program that prompts the user to enter five numbers, invokes the method to find the lcm of these numbers, and displays the lcm.