1. Write a program that takes three numbers (a,b,c) from the user as input and finds the median of the three. The program has a method called median that takes 3 numbers as the parameter and returns the median. Use if-then-else statements to find the median. You can assume the three numbers are not the same. Sample Example: Enter 3 numbers 10 2 13 The median is 10 public class Median{ public static void main(String[] args){ Scanner input = new int a = int b = int c =
Q: Q1. Write a String method called "isEven" that takes n as parameter of integer type, and returns…
A: NOTE: We’ll answer the first question since the exact one wasn’t specified. Please submit a new…
Q: create a class that asks a user for 2 string inputs (USE The Java. Util. SCANNER) -compare…
A: write a Program in java on string operations given in problem statement
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: Write a method that takes a String name parameter. The method asks the user to input an hour value.…
A: The method accepts a String which is name It prompts user for hours If hours<12 then it's morning…
Q: Java program Write and test a void method called inOrder() that takes three strings and prints them…
A: Code: import java.util.Scanner; public class AlphabeticalOrder { //function to sort the strings…
Q: Question 2: Take a lowercase word as an input from the user. Modify the word in such a way that the…
A: Note: You have not specified any programming language, so I have written a python code to answer the…
Q: You can just provide code as you don't have required utility class, Please provide explanation and…
A: import java.util.*;import java.lang.*;import java.io.*; class Codechef{ public static void…
Q: Write a program that prints out true or false depending on comparisons that you make. Make sure that…
A: All types of operators are used in the code + - * / % > >= == <= < != The complete…
Q: a one-dimensional string array and string You need to search for the given array and return the…
A: class Main{ static int Search(int array[], int al, int y) //counts the number of occurrences of a…
Q: This is java problem: Write a program that simulates tossing a coin. Prompt the user for how many…
A: Following is the java program using main() method to ask the user number of tosses then call the…
Q: Two integers are said to be relatively prime if their greatest common divisor (GCD) is one. For…
A: import java.util.Scanner; class RelativelyPrime { public static void relativelyPrime(int A, int…
Q: Write a method that takes a String array and an integer as parameters and prints the Strings in the…
A: Use length() method available in String class to find the length of string and then compare this…
Q: 4) Create a method which takes two int parameters and swaps them. Print the values before and after…
A: #include <iostream> using namespace std; int main() { int x,y; cout<<"Enter 1st…
Q: Given an anonymous word W and a text M. You are required to write a method which takes W and M as…
A: Algorithm: Start Read word W and text M Define a method anonymous_word() which takes W,M as…
Q: Write a program that asks the user to enter a character. Then pass the character to the following…
A: Program description: The java progrm,Main.java prompts the user to enter a character from the…
Q: Class: DoubleMethod Write a method using the header below public static double…
A: Here in this program, I have completed the method which will take a prompt as an argument and return…
Q: write a public static method named replaceFirst that takes in a String s and a char c as arguments.…
A: logic:- if string is null return null else if string is blank return blank else res =…
Q: Solved in Java Write a method maxMagnitude() with two integer input parameters that returns…
A: The Answer start from step-2.
Q: Write a program that will prompt the user to enter a sentence (string data), read that entire…
A: I give the code in Java along with code and output screenshot
Q: create a class that asks a user for 2 string inputs (USE The Java. Util. SCANNER) -compare the…
A: (Disclaimer: Since you have asked multiple questions, we will solve the first question for you. If…
Q: public static void main(String [] args) { int num1 = 5, num2 = 10; swap(num1, num2);…
A: Given: public static void main(String [] args){ int num1 = 5, num2 = 10; swap(num1, num2);…
Q: In Java Write a program that reads a list of words. Then, the program outputs those words and…
A: Actually, java is a object oriented programming language,.
Q: Modify the program below to create a class that contains a static method; the method takes a string…
A: import java.util.*;public class HelloWorld{ public static boolean checkRepeat(String s){…
Q: Write a method that checks whether two words are anagrams. Two words are anagrams if they contain…
A: #include <bits/stdc++.h>using namespace std; bool areAnagram(string str1, string str2){ int n1…
Q: Print person1's kids, call the incNumKids() method, and print again, outputting text as below. End…
A: Program code: File name: PersonInfo.java //import the required packages import java.util.*;…
Q: Program61.java Write a program that prompts an employee to enter his/her hourly pay rate and hours…
A: According to Bartleby policy, I have provided program61.java in Step 2.
Q: *in java* Complete method printPopcornTime(), with int parameter bagOunces, and void return type.…
A: import java.util.Scanner; public class PopcornTimer {public static void printPopcornTime(int…
Q: In Java. Write a method with the following header to format the integer with the specified width.…
A: public String format(int number, int width) The method returns a string for the number with one or…
Q: Write a Java method splitName() that takes a string (that contains 1 word or more…
A: Here I have created a function named splitName(). In this function, I have first of all converted…
Q: basic java please Write a method starTheString that accepts a string of any size/length and a…
A: Here, Code instructions are given.
Q: Write a program that will prompt the user to enter a sentence (string data), read that entire…
A: Given something from the client, the program will make a 3D shape out of it where the word will be…
Q: Write a method that prints numbers using the following header:public static void printNumbers(int…
A: Write a test program to prints the numbers between num1 and num2 with the specified numbers per line…
Q: A pet shop wants to give a discount to its clients if they buy one or more pets and at least four…
A: public class Main{ public static void discount(double prices[],boolean isPet[],int nItems) {…
Q: Complete the convert() method that casts the parameter from a double to an integer and returns the…
A: Algorithm: Start Implement convert() method which takes a double number as argument and returns an…
Q: 1. Write down a method that will take an integer as a parameter and will return 1 if the integer is…
A: Program description: n is the user input integer variable that is used to store the upper limit of…
Q: A pet shop wants to give a discount to its clients if they buy one or more pets and at least five…
A: The answer given as below:
Q: Write a method with the following header to format the integerwith the specified width.public static…
A: Here, you need to write one method called "format" , which will return a string for the number with…
Q: Complete the method definition to return the hours given minutes. Output for sample program:3.5…
A: As it is only needed to complete the method definition, but the whole algorithm works in the steps…
Q: 2. A pentagonal number is defined as n(3n-1)/2 for n = 1, 2, ..., etc.. Therefo the first few…
A: Use a loop to call the method 100 times and for every 10 numbers, we can make use of conditional…
Q: Write in Java. Write a method with the following header to format the integer with the specified…
A: import java.util.*;import java.lang.*;import java.io.*; class HW2_P1{ public static String…
Q: USING JAVA Write a Java method named check() that checks the validity of a password received as…
A: Here I have created a method named check(). In this method, I have created for loop to iterate over…
Q: **JAVA LANGUAGE** Beginner Level Suppose that a Scanner object contains a bunch of tokens all on…
A: Steps followed for partialSum method: Declaring and initializing the total variable and X…
Q: In your program, write a method that accepts a positive integer and returns true if the number is a…
A: C# program: Part1: public Boolean isPrime(int prime) { for (int number =…
Q: Write a java method that receives a string containing letters of the English alphabet and then…
A: Java is a programming language. It contains extensive libraries (package). It can be used to create…
Q: Write a method with the following header that returns a pentagonal number: public static int…
A: The nth pentagonal number pn is given by the formula: pn = (3n2 - n) / 2 for n >= 1.
Q: Write a method hat takes a list of Book and a String as parameters. This method supposed to search a…
A: Book is a class and should has basic attributes to store the name and info which are used to compare…
Q: 2. Write a method that returns the ceiling of an input double. Note, this function always returns…
A: We have provided java code according to instructions provided with Utilities class and Tester class…
Q: 1) Write a simple program whose main method will repeatedly ask the user for an integer number and…
A: The program reads the input stores it into variable. It then calls the isPrime function and stores…
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
- Write a method that returns a random number from alist of numbers passed in the argument. The method header is specified as follows:public static int getRandom(int... numbers)Create a program that asks the user for two doubles. Your program will include a static method called doMath. It should take in the two doubles that the user entered, add them together, multiply the answer by 2, and then round to the nearest integer. You will return this integer. Your static method only performs the math and returns the integer answer. Your static method should not ask for input or print output. Your main method should ask for input, call the method and pass in the user’s two values, and then print the result that is returned from the doMath method. This program does not have to loop and does not have to have any try/catch blocks. Note: If your program does not perform the required tasks in a separate static method, you will not get any credit for this program. Example: Enter two numbers and I will do math things with them. >>>5.1 >>>3.2A pentagonal number is defined as n(3n−1) ∕ 2 for n = 1, 2, . . ., etc.. Therefore, the first few numbers are 1, 5, 12, 22, . . . . Write a method with the following header that returns a pentagonal number:public static int getPentagonalNumber(int n) For example, getPentagonalNumber(1) returns 1 and getPentagonalNumber(2) returns 5. In Java, Write a test program that uses this method to display the first 100 pentagonal numbers with 10 numbers on each line. Numbers are separated by exactly one space.
- 6.17 LAB: Max magnitude Write a method maxMagnitude() with two integer input parameters that returns the largest magnitude value. Use the method in a program that takes two integer inputs, and outputs the largest magnitude value. Ex: If the inputs are: 5 7 the method returns: 7 Ex: If the inputs are: -8 -2 the method returns: -8 Note: The method does not just return the largest value, which for -8 -2 would be -2. Though not necessary, you may use the absolute-value built-in math method. Your program must define and call a method:public static int maxMagnitude(int userVal1, int userVal2) tested with 5,7 -8,-2, 25,-50 import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner input = new…Write a method orderFood() for the class Food that simulates ordering food. The method takes an integer as argument, which indicates the number of portions that are ordered. It then prints out a string showing the number of portions and the type of food ordered. The string needs to have the format as shown in the examples below. PythonUsing Java, Write a method named isEven that accepts an int argument. The method should return true if the argument is even, or false otherwise. Also write a program to test your method.
- 2. Write a java program which will input an integer value from the user (Use Scanner class). Your program will have mathOper() method in addition to the main() method.The main() method will be responsible for:a. extracting the 1's digit (ones), the 10's digit (tens), and any digits larger than the 10's digit. For instance, if the input is 3562, the 1's digit would be 2, the 10's digit would be 6, and the remaining digits would be 35.b. call the mathOper() method with these 3 values,c. print the results to the screen.The mathOper() method will make the following calculations:a. Multiply the 1's digit by 7, subtract the result by 2 and then divide that by 5.b. Add 3.5 to the 10's digit, multiply the result by 4.3 and then divide that by 2.c. Subtract 5 from the remaining digits, multiply the result by 3, find the remainder after dividing that by 7, and then add 6 to the remainder value.d. Add the 3 values obtained from ‘a’, ‘b’, and ‘c’ operations.e. Return the final value.Sample output…Modify the program below to create a class that contains a static method; the method takes a string as a parameter and returns a boolean value indicating whether the parameter string has repeated characters in it or not. That is, return true if there is at least one character which appears more than once in the string. The string should be input by the .user import java .util.*; public class Main{public static void main(String args[]){Scanner scn=new Scanner(System.in); // Input the string from userSystem.out.println ( "Enter the String to check for duplicate characters:");String str = scn.next();// Check is variable to store bool value true// It will change to true if there are repeated charactersboolean check=false;for (int a = 0; a < str.length(); a++)for (int b = a + 1; b < str.length(); b++)if (str.charAt(a) == str.charAt(b))check=true;// If check is true then string has repeated characters if (check)System.out.println("The String " + str + " has repeated…Program62.javaWrite a program that prompts for a full name (first and last) and assigns it to one string. The program then passes the full name to a void method as its sole parameter. The void method should print the first name, on one line, as many times as indicated by the length of the last name. Sample Output (image below) Program64.javaWrite a program that demonstrates method overloading by defining and calling methods that return the area of a triangle, a rectangle, or a square.
- Write a method thatcomputes future investment value at a given interest rate for a specified numberof years. Use the following method header:public static double futureInvestmentValue(double investmentAmount, double monthlyInterestRate,int years)For example, futureInvestmentValue(10000, 0.05/12, 5) returns12833.59.Write a test program that prompts the user to enter the investment amount (e.g.,1,000) and the interest rate (e.g., 9%) and prints a table that displays future valuefor the years from 1 to 30, as shown below: The amount invested: 1000Annual interest rate: 9Years Future Value1 1093.802 1196.41...29 13467.2530 14730.57In Java Write a RainFall class that stores the total rainfall for each of 12 months into anarray of doubles. The program should have methods that return the following: Total rainfall for the year, The average monthly rainfall The month with the most rain The month with the least rainThe program should not accept negative numbers for monthly rainfall figures.You may use the following main function to test the methods:public static void main(String[] args) { // Array with this year's rainfall data double[] thisYear = {1.6, 2.1, 1.7, 3.5, 2.6, 3.7, 3.9, 2.6, 2.9, 4.3, 2.4, 3.7 }; int high; // To hold the month with the highest amount int low; // To hold the month with the lowest amount // Display the total rainfall. System.out.println("The total rainfall for this year is " + getTotalRainFall(thisYear)); // Display the average rainfall. System.out.println("The average rainfall for this year is " + getAverageRainFall(thisYear)); // Get and display the month with the highest rainfall.…In this challenge, you need to implement a method which squares passing variables and return their sum. Problem Statement # Implement a method squareSum(double num1, double num2, double num3) in a class SquareSum which takes three numbers, square them and returns their sum. Input: # Three floating point numbers. Output: # Sum of the squares of passing numbers Sample Input # 2, 3, 4 Sample Output # 29