Please I need help. Java language
import java.util.Arrays;
public class Main {
public static String curveScores(String str){
String tokens[] = str.split(" ");
int max = -1, index = -1;
for(int i=0; i<tokens.length; ++i){
if(Integer.parseInt(tokens[i]) > max){
max = Integer.parseInt(tokens[i]);
index = i;
}
}
int diff = 100 - max;
for(int i=0; i<tokens.length; ++i){
int num = Integer.parseInt(tokens[i]);
if(i != index)
num = num + diff;
else
num = 100;
tokens[i] = num+"";
}
return Arrays.toString(tokens);
}
public static void main(String[] args) {
System.out.println(curveScores("45 85 90 80 30"));
}
}
=============================================
SEE OUTPUT
PLEASE COMMENT if there is any concern.
=============================
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...
language is java
Restrictions: You are not allowed to use anything from the String, StringBuilder, or Wrapper classes. In general, you may not use anything from any other Java classes, unless otherwise specified. You are not allowed to use String literals in your code ("this is a string literal"). You are not allowed to use String objects in your code. The methods must be implemented by manipulating the data field array, The CSString Class: NOTE: Pay very careful attention to...
PLEASE HELP!!!I need help with the following JAVA PROGRAMS.
Please ready carefully. So this comes from tony
gaddis starting out with java book. I have included the screenshot
of the problems for reference. I need HELP implementing these two
problems TOGETHER. There should be TWO class files. One which has
TWO methods (one to implement problem 8, and one to implement
problem 9). The second class should consist of the MAIN program
with the MAIN method which calls those methods....
Language: Python Function name : findwaldo Parameters : string Returns: int Description: Write a recursive function that takes in a string containing some combination of letters, numbers, and spaces, and return the starting index of the first instance of “waldo” contained in that string. If the string does not contain “waldo”, return -1. This function IS case sensitive, so “waldo” is not the same as “WALDO”. Code using string functions such as .index() and .find() that oversimplify the problem will...
Help with Java function. Suppose I have a string input that contains letters followed by numbers. Can someone write a function that only returns the number values? Ex: Input "dog12" should return 12. Edit: It should return 12 as an integer.
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...