Please I need help. Java language
Code - Main.java
public class Main
{
//getScore function take string of score
public static String getScore(String str){
//split the String using split function with " " as argument and
convert into String array
String[] arrOfStr = str.split(" ");
//get the first number and convert to String
int num1 = Integer.parseInt(arrOfStr[0]);
//get the second number and convert to String
int num2 = Integer.parseInt(arrOfStr[1]);
//get the third number and convert to String
int num3 = Integer.parseInt(arrOfStr[2]);
//initialzie vairble
int max = 0,difference;
//get the maximum among three vairable
if(num1 > num2){
if(num1>num3){
max = num1;
//initialzie max num1 to 100
num1 = 100;
}
}
else{
if(num2>num3){
max = num2;
//initialzie max num2 to 100
num2 = 100;
}
else{
//initialzie max num3 to 100
max = num3;
num3 = 100;
}
}
//you will get the max
//get the difference from 100
difference = 100 - max;
//add the difference to number which are not max
if(num1 !=100){
num1+=difference;
}
//add the difference to number which are not max
if (num2 != 100){
num2+=difference;
}
//add the difference to number which are not max
if(num3 !=100){
num3+=difference;
}
//return string
return num1+" "+num2+" "+num3;
}
public static void main(String[] args) {
//call function getScore and print the return
string
System.out.println(getScore("45 85
90"));
}
}
Screenshots -
pls do give a like and ask multiple quesiton in different parts we are told to answer first in case of multiplt, thanks
Please I need help. Java language Method name: getScores Return value is a String of numbers...
Please I need help. Java language Method name: getScores Return value is a String of numbers scaled so that the highest number in the parameter String becomes 100 and all the other numbers are moved up by the same amount. This String should also be numbers separated by spaces with no additional characters. The order of the numbers should stay the same, so that a number in the original string has the equivalent scaled number in the returned string in...
1.Method name: findSmallestPositiveNumber Parameter(s): A String containing integer numbers separated by spaces. There must be at least one positive number in the String. Return value: An int value that is the smallest number greater than 0 in the input string. Example: findSmallestPositiveNumber("2 -4 5") should return 2. Note: Even though I put this first, I would consider working on this later. The other methods are basically just applying the patterns we looked at in class. This one is similar but...
The goal of this assignment is to use loop patterns to solve a variety of problems Starting 1. In Eclipse, create a new project or use an assignments one. Add a package a4, and a class SearchAndOptimizingLoops to that package. Copy and paste Picture.java and an image file from prior work into this package (Picture.java should update itself to the a4 package) 2. In your class, implement the static methods specified below 3. All methods you write should have a...
I need java code for the following problem.
Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...
use Java and it must work for any name
String Manipulator Write a program to manipulate Strings. Store your full name into one String variable. It must include first name, middle name, last name, cach separated by spaces. Spaces could vary. If you do not have a middle name make up one For example the string to be processed could be any of the following John Plain Doe John Plain Doc John Plain Doe Your program must be able to...
Within a class I need to create a method that is return type boolean. This method accepts a String as a parameter that represents a file path. If the file path exist it should return true else it returns false. When I call the method it should load the file based on the parameter that was passed. (This is done in JAVA)
Write a method called printReverse() that
takes a string and uses recursion to print the contents of the
string in reverse order. The string itself should
not be reversed; it must be left in its
original form.
The method has the following header:
void printReverse(String s, int i)
where s is a reference to the string, and i is an integer
parameter that you may use as you see fit. You do not need
to code up this method as...
// I need help with the following questions. Please use java programming ECLIPSE language to solve the questions. YOU ONLY NEED TO DIRECTLY COPY IT IN YOUR ECLIPSE APPLICATION AND RUN IT. I NEED THOSE PART WHICH IS SAYS --> "TO BE COMPLETED" I NEED HELP WITH [GET*] AND [REPLACE ALL] AND [ADD INT DOUBLE] PLEASE. import java.util.ArrayList; public class CustomArrayList { //instance variables public int[] data; //data.length gives the capacity public int nItems; //nItems gives items currently in the...
Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: o Write a method called cubeIt that accepts one integer parameter and returns the value raised to the third power as an integer. 2. Write a method called randomInRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. o Write a method called larger that accepts two double parameters and...
JAVA 1.Write a static method named getMaxEven(numbers) which takes an array of positive integers as a parameter. This method calculates and returns the largest even number in the list. If there are no even numbers in the array, the method should return 0. You can assume that the array is not empty. For example: Test Result int[] values = {1, 4, 5, 9}; System.out.println(getMaxEven(values)); 4 System.out.println(getMaxEven(new int[]{1, 3, 5, 9})); 0 public static int --------------------------------------------------------------------------------- 2. Write a static method...