A car is unreliable if it is a Yugo. Yugo is (or was) a make of car. Any other car is reliable if it has < 80000 miles on it. A Mercedes is reliable if it has < 150000 miles on it. public static boolean isReliable(String make, int mileage) {
Q: a) Briefly explain the parameters (e1, e2, distanceX, and distanceY) in the onScroll callbacks.…
A: To detect the user gesture Gester Detector is use. It android there is also have the gesture…
Q: Study the following program and show what it will print on the screen.// The Works of Wolfgangpublic…
A: Given: Study the following program and show what it will print on the screen.// The Works of…
Q: Write multiple if statements:If carYear is before 1967, print "Probably has few safety features."…
A: Multiple if-statement includes many if-statements. In multiple if-statement, one or more…
Q: We have to dogs x and y, and the parameters xSmile and ySmile indicate if each is smiling. We are in…
A: Write a JAVA program to input the values of two boolean variables xSmile and ySmile. Then print…
Q: Change Java code below
A: The Java programming language is an object-oriented programming language, that's used to develop web…
Q: Will the code compile? If yes, determine the output. If no, state why. class Pet { public Pet(int…
A: Please find the program and the reason for the error in step 2.
Q: Complete the Team class implementation. For the instance method get_win_percentage(), the formula…
A: Floating point Division is the division in which if one or two sides has a floating point number,…
Q: Find the output of the following code public class Q6{ public static void main(String[] arg) {…
A: public class Q6{ public static void main(String args[]){ double a=11.5;…
Q: Finish the Jave program to show the outputs bellow:
A: mport java.io.*;import java.util.*; public class Phone{ String name,model,Color; int…
Q: a) FindMinIterative public int FindMin(int[] arr) { int x = arr[0];…
A: Please refer below for your reference: Time complexitites are below: a) FindMinIterative public int…
Q: a. public static boolean isEven(int n1, int n2) b. public static bool isEven(int nl) c. public…
A: The method header comprises the access modifiers (public static), return type (int), method name…
Q: Find the output of the following code. Public class Solution{ Public static void main(String…
A: We are asked the output of given java code.
Q: Write an if-else statement with multiple branches. If givenYear is 2101 or greater, print "Distant…
A: The below given java program will obey the following rubrics: Importing essential header files.…
Q: Write a statement that increases numPeople by 5. Ex: If numPeople is initially 10, the output is:…
A: According to the guideline we are allowed to answer only the first question. - The first question…
Q: Write an expression that prints "Special number" if specialNum is -99, 0, or 44.…
A: Given: To write the expression within the if statement so that the code gives correct output. The…
Q: Short answer with explanation. What is the output of the following code and explain your answer:…
A: The above code generate the compile time error because the method printInt() is not a static type…
Q: in python "Anagram Make a method is_anagram_of(a,b) that tests if a is an anagram of b. A string a…
A: Hi. Let's move on to the code in the next step. I have included comments in the code that will…
Q: Complete the below code in such a way to produce output 2 public class Main public static void…
A: This is a JAVA langauge problem. In this question, we have to fill in the two blanks. So that the…
Q: Write multiple if statements: If carYear is before 1967, print "Probably has few safety features."…
A: According to the information given:- We have to follow the instruction mentioned in order to get…
Q: Can you helo me Fix the typo in the following program. My solution should be a single line of code…
A: the code is below:
Q: Given a list of strings of bracket characters: {}), the string of brackets is balanced under the…
A: import java.util.*;import java.lang.*;//Parser classclass Parser{ //isBalanced function that…
Q: Analyze the following code: public class Test { public static void main(String[] args) { Bb = new…
A: Hello Student Greeting Hope you are doing great. I will try my best to answer your question. Thank…
Q: Inside class StaticMethods., create the static and OVERLOADED method cubeNumber that takes as an…
A: use Double.parseDouble to convert string to double.
Q: Getting a error message and I dont understand why public class DebugTwo2 { public static void…
A: Explanation :- You have not closes the parentheses of your code, So that why you getting an error…
Q: public class CAT_ONE { public static int solve(int n) { if (n <= 1) return n; return solve(n-1) +…
A: Task : Re-write the given program to improve the time efficiency.
Q: public class Test public static void main (String [] args) { System.out.println ("The average is " +…
A: returnValueType for the method average is "Double"
Q: Create a flowchart for this Java program class Test { public static void main(String[] args) { for…
A: PROGRAM: //Defining class class Test { //Defining main() public static void main(String[] args) {…
Q: public class Point ( int x; int y; public Point(){ this.y = 10; this.x = 10; public Point(int x){…
A: The given code is below: public class Point { int x; int y; public Point(){…
Q: there is a ternary operator like this int x= a>b ? a : b ; so there is 3 number ,x,,y,z if…
A: so, here we have to convert the if-else logic code to , using Ternary Operator code. we can do it…
Q: Given a String check to see if the parenthesis contained in the String are balanced. Balanced…
A:
Q: For the following code, which statements are NOT true? public class Person { private double weight;…
A: Required:
Q: Write the printItem() method for the base class. in Java Sample output for below program: Last…
A: // ===== Code from file ItemInventory.java =====import java.util.ArrayList; public class…
Q: Select the header of a method for testing whether a @ public static boolean isOdd(int nl, number is…
A: Lets see the solution.
Q: PROGRAM SIMULATION. Understand the given JAVA program and write the output. b. public class…
A: There should be one change in the code that is, the method doIt inside class ChangeIt should be…
Q: Write multiple if statements: If carYear is before 1967, print "Probably has few safety features."…
A: 1. Taking User input for the carYear variable. 2. Writing multiple if statements as per given…
Q: public class GameOfLife { private BooleanProperty[][] cells; public GameOfLife() { cells = new…
A: Given: public class GameOfLife { private BooleanProperty[][] cells; public GameOfLife() {…
Q: identify the errors in the following class and how it can be fixed? public class Test { public…
A: If we look at the variables x and y , they are not initialized with any value. And this value give…
Q: Debug this program to create the desired result attached in the picture. public class Library { //…
A: Here I have defined a static class named Book with one data member and constructor inside the class…
Q: What is the output of executing the following code? public class Test { public static void…
A: JAVA CODE:- public class Main {public static void main(String[] args) {m(new…
Q: private double price; private int range; // constructor ... nc public double getPric { return price;…
A: CODE public boolean test(Node[] list , int n){ int i=1; for(: i<n;i++)…
Q: 2. Every circle has a center and a radius. - Given the radius, we can determine the circle's area…
A: Here I written Java code as per given problem below. I hope you like it.
Q: A bank account earns interest once per year. Compute the interest earned in the first and second…
A: Interest calculation Logic: - The interest for one year is calculated by making use of the…
Q: Trace through the following program and Show the Ol public class Employee { private static int empID…
A: public class Employee{ private static int empID = 11111; private String name, position;…
Q: A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are…
A: The program is written in Java. Please find the source code and output in the following steps.
Q: identify the errors in the following class and how it can be fixed public class Test { public static…
A: This code looks very good as it doesn't have any syntax errors But the only error is x and y are…
Q: Medium resistance: This class includes all resistances of values between 10 Q and 100 k Q. Most of…
A: Below is the complete solution and explanation to the given question in detail.
Q: public class F { private boolean x; public static void main (String[] args) { Ff = newF ();…
A: Since no information is given about whether these two classes belong to same java filer different…
Q: Given that a method receives three parameters a, b, c, of type double, write some code, to be…
A: logic:- define a method taking three double parameter a,b and c. use if else to set condition for…
Q: algorithm for the program
A: algorithm for simple electricity bill calculationFirst 100 units amount to be paid = 100 X 0.0 =…
Step by step
Solved in 3 steps with 1 images
- Given the following recursive method:public static int think(int x) {if(x<10)if(x%2!=0)return x;elsereturn 0;elseif(x%2!=0)return x%10 + think(x/10);elsereturn think(x/10);}Trace (in details) the calling of the above method with any input from your choice such that thereturned value will be 19Write java method fullName with a return type of void and accept a name. The method will display the abbreviation of the firstname and middle name except for the lastname. For example, if name is Yule Plaza Sanchez it will display: Y.P.Sanchez For example: Test Result fullName("Yule Plaza Sanchez"); Y.P.Sanchez fullName("Yule Josef Plaza Sanchez"); Y.J.P.SanchezMachine Problem #2. Write a method-oriented Java program that asks the user to input two numbers and getthe sum, difference, product, and average of the numbers inputted. Class Name: MethodFourOperationsSample Input/OutputEnter num1 :90Enter num 2:88The sum is: 178The difference is: 2The product is: 7920The quotient is: 89
- Given the following recursive method: public static int think(int x) { if(x<10) if(x%2!=0) return x; else return 0; else if(x%2!=0) return x%10 + think(x/10); else return think(x/10); } Trace (in details) the calling of the above method with any input from your choice such that the returned value will be 19Correct any mistake(s) in the following Java code and write your answer on the right (c) In the main method we have the following Java statements: double balance=20000; printBalance( ); System.out.println(calcBalance()); where the two methods are declared below: public static void printBalance( ) { System.out.println(“Balance is ”+balance); } public static double calcBalance(){ balance = balance*Math.pow(1+0.05); }Write a method java program using the following . base shipping price: 2 pounds or less $2.00, 2-5 pounds $3.00, 5 pounds or more $4.00 discounts: 15% for premium, 10% for regular and otherwise a zero percent discount on base shipping price is given special handling: category 1 (good handling) $3.00, category 2 (fast handling) $2.00, category 3 (cheap handling) $1.00. Any other number will result in a charge of $3.00. Charge for requried insurance: 10% of the amount enter for insurance.
- Write a public method that takes two arguments: a double representing the number of hours worked and a double representing the hourly pay, and returns a double representing the weekly pay. If the hours are less than or equal to 40, the weekly pay should be hours times hourly pay. If the hours are greater than 40 and less than 80, the weekly pay should be 40 times the hourly pay, plus the hours in excess of 40 times hourly pay times 2.0. If the hours worked are entered as less than zero or greater than 80, print an error message saying "incorrect number of hours entered" and return 0.0;Write a static method userPasswordMatch(): Takes 2 String (s1, s2) input Define a boolean variable which you will return at the end of the method Check if String s1 and s2 satisfy username and password pair using “if” and “if else” Return the boolean variable as true Main Method: Set a counter to keep track how many times this program can get input from user In a loop, ask user for input: username and password Check these inputs using userPasswordMatch() method Check If userPasswordMatch() returns false then print: Username or password incorrect. And check if the value of the counter is less than 3, if that is, then print: Try again If the value of the counter is greater than 3, then print: too many attempts Otherwise, print: Login successfulComplete 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. coede used: class Team: def __init__(self): self.team_name = 'none' self.team_wins = 0 self.team_losses = 0 # TODO: Define get_win_percentage() if __name__ == "__main__": team = Team() team_name = input() team_wins = int(input()) team_losses = int(input()) team.team_name = team_name team.team_wins = team_wins team.team_losses = team_losses if team.get_win_percentage() >= 0.5: print('Congratulations, Team', team.team_name,'has a winning average!') else:…
- Complete the method definition to return the hours given minutes. Output for sample program:3.5 -java code- import java.util.Scanner;public class HourToMinConv { public static double getMinutesAsHours(double origMinutes) { /* Your solution goes here */ } public static void main (String [] args) { Scanner scnr = new Scanner(System.in); double minutes; minutes = scnr.nextDouble(); // Will be run with 210.0, 3600.0, and 0.0. System.out.println(getMinutesAsHours(minutes)); }}Write a recursive method called drawTriangle() that outputs lines of '*' to form an upside down isosceles triangle. Method drawTriangle() has one parameter, an integer representing the base length of the triangle. Assume the base length is always odd and less than 20. Output 9 spaces before the first '*' on the last line for correct formatting. Hint: The number of '*' decreases by 2 for every line drawn. Ex: If the input of the program is: 3 the method drawTriangle() outputs: *** * Ex: If the input of the program is: 19 the method drawTriangle() outputs: ******************* ***************** *************** ************* *********** ********* ******* ***** *** * Note: No space is output before the first '*' on the first line when the base length is 19.Help m Complete method printPopcornTime(), with int parameter bagOunces, and void return type. If bagOunces is less than 2, print "Too small". If greater than 10, print "Too large". Otherwise, compute and print 6 * bagOunces followed by " seconds". End with a newline. Example output for ounces = 7: 42 seconds import java.util.Scanner; public class PopcornTimer {public static void printPopcornTime(int bagOunces) { /* Your solution goes here */ } public static void main (String [] args) {Scanner scnr = new Scanner(System.in);int userOunces; userOunces = scnr.nextInt();printPopcornTime(userOunces);}}l.