1. For each of the following tasks, design a class (i.e., static)method heading
ID: 3614684 • Letter: 1
Question
1. For each of the following tasks, design a class (i.e., static)method heading with an appropriate name, parameters, and returntype (or void). You do not need to write the method body. Forexample, the heading for a method that computes and returns thelargest of two real numbers could be something like thisprivate static double max(double x, double y).
- The task is to convert a given integer grade (0..100) into acorresponding letter grade.
- The task is to compute the state tax on an item, given the costof the item and the tax rate.
- Given three names, the task is to output them in aphabeticalorder.
- Given a sentence, the task is to print each word in thesentence on a separate line of output.
- Given a string and a character, the task is return the stringobtained by removing all occurrences of the given character fromthe given string.
- What is the output produced by the following programs?
-
public class ChangeParam
{
public static void main(String[] args)
{
int i = 1;
double x = 3.4;
String s = "hi!";
System.out.println(i + " " + x + " " + s);
changeUs(i, x, s);
System.out.println(i + " " + x + " " + s);
}
private static void changeUs(int j, double y, String t)
{
j = 7;
y = -1.2;
t = "there";
System.out.println(j + " " + y + " " + t);
}
} -
public class TraceMe
{
public static void main(String[] args)
{
printBox(5, 3);
}
private static void printBox(int rows, int columns)
{
int i = 0;
while (i < rows)
{
int j = 0;
while (j < columns)
{
if ((i % 2) == (j % 2))
{
System.out.print('A');
}
else
{
System.out.print('B');
}
j = j + 1;
}
System.out.println();
i = i + 1;
}
}
} -
public class ItsAMistery
{
public static void main(String[] args)
{
mistery("123456789");
}
private static void mistery(String str)
{
int i = 0;
while (i < str.length())
{
System.out.print(str.charAt((i + 5) % str.length()));
i = i + 1;
}
}
}
-
- The task is to convert a given integer grade (0..100) into acorresponding letter grade.
- The task is to compute the state tax on an item, given the costof the item and the tax rate.
- Given three names, the task is to output them in aphabeticalorder.
- Given a sentence, the task is to print each word in thesentence on a separate line of output.
- Given a string and a character, the task is return the stringobtained by removing all occurrences of the given character fromthe given string.
Explanation / Answer
Dear... Here is the code.. 1) The output of changeprm class is 1 3.4 hi! 7 -1.2 there 1 3.4 hi! The output of TraceMe class is BAB ABA BAB ABA The output of ItsMystery class is 678912345 Hope this will help you... Hope this will help you...Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.