Question

Please I need help. Java language Method name: getScores Return value is a String of numbers...

Please I need help. Java language

  1. 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 the same place.
    Example: curveScores("45 85 90") would return "55 95 100".
  2. Method name: encloseColor
    Return valu is boolean value. Return true if the Color parameter matches one of the pixels in the image and false otherwise. A color match is done by using the .equals method rather than ==.
    Example: For a 1 pixel picture with a color of (100, 200, 50) and a color to search for of (100, 100, 100), this method would return false.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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 -

55 95 100 ... Program finished with exit code o Press ENTER to exit console.I

pls do give a like and ask multiple quesiton in different parts we are told to answer first in case of multiplt, thanks

Add a comment
Know the answer?
Add Answer to:
Please I need help. Java language Method name: getScores Return value is a String of numbers...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The goal of this assignment is to use loop patterns to solve a variety of problems...

    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 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...

    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...

  • Write a method called printReverse() that takes a string and uses recursion to print the contents...

    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...

    // 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...

  • JAVA 1.Write a static method named getMaxEven(numbers) which takes an array of positive integers as a...

    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...

  • language is java Restrictions: You are not allowed to use anything from the String, StringBuilder, or...

    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...

  • public static boolean isArithmetic(java.lang.String text) Given a string of text containing numbers separated by commas, returns...

    public static boolean isArithmetic(java.lang.String text) Given a string of text containing numbers separated by commas, returns true if the numbers form an arithmetic sequence (a sequence in which each value differs from the previous one by a fixed amount). For example, given "2,4,6,8", the method returns true given "-2,5,12,19,26", returns true given "2,4,7", returns false given "1,2,23skidoo", returns false The method should return true for any string containing two or fewer numbers and false for any invalid string. Assume that...

  • Need help with these two questions String outputBreadthFirstSearch(): returns a string represenng a breadth first traversal....

    Need help with these two questions String outputBreadthFirstSearch(): returns a string represenng a breadth first traversal. So, for example, for the tree shown in Figure 1, the method should output the string "bcaahttaetersse" 4. String outputDepthFirstSearch(): returns a string represenng a pre order depth first traversal. So, for example, for the tree shown in Figure 1, the method should output the string "batcathateersse This is my code so far public class Trie { final TrieNode root; public Trie() { this.root...

  • using java String Challenge Have the function StringChallenge(str) read str which will contain two strings...

    Have the function wildcard(str) read str which will contain two strings separated by a space.The first string will consist of the following sets of characters: +, *, $ and {N} which is optional.The plus (+) character represents a single alphabetic character, the ($) character represents anumber between 1-9, and asterisk (*) represents a sequence of the same character of length 3unless it is followed by {N} which represents how many characters would appear in thesequence where N will be at...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT