Combine into java programs that give the solution of to these projets: Please I
ID: 3542315 • Letter: C
Question
Combine into java programs that give the solution of to these projets:
Please I need the java projets not the code.
1-------- Write a fragment of code that will change the integer value stored in x as follows. if x is even, divide x by2. if x is odd, multiply x by 3 and substract1.
2--------consider the following fragment of code:
if (x > 5)
{
System.out.println("A");
if (x < 10)
System.out.println("B");
}
else
System.out.println("C");
What is displayed if x is
a.4; b.5; c.6; d.9; e.10; f.11;
3--------- we would like to asses a service charge for cashing a check. the service charge depends on the amount of the checks. if the checks is less than $10 we will charge $1. if the amount is greater than $10 but less than $100 we will charge 10 percent of the amount. if the amount is greater than $100 but less than $ 1000, we will charge $5 plus 5 percent of the amount. if the value is over $1000 we will charge $ 40 plus 1 percent of the amount. use multibranch if_else statement in fragment of code to compute the service charge.
4---------The following code fragemnt will not compile. why ?
if ! x> x+y
x=2*x;
else
x=x+3;
Explanation / Answer
Let me know if this is what you're looking for. Answer for #1:
public class Problem1
{
public static void main (String[] args)
{
int x = 5;
System.out.println("Original value of x: " + x);
if (x%2 == 0)
{
x = x/2;
System.out.println("x was even and has been divided by 2.");
System.out.println("x now equals: " + x);
}
else
{
x = (x*3)-1;
System.out.println("x was odd and has been multiplied by 3 and had 1 subtracted from it.");
System.out.println("x now equals: " +x);
}
}
}