public class Main
{
public static void main(String[] args) {
int x=5,y=20;
if(y==20)
x=0;
System.out.println("X is
"+x);
}
}

2)
public class Main
{
public static void main(String[] args) {
int hours=50;
double payrate=4;
System.out.println("Payrate before
checking is "+payrate);
if(hours>40)
payrate=payrate*1.5;
System.out.println("Payrate After
checking is "+payrate);
}
}

3)public class Main
{
public static void main(String[] args) {
int amount1=60,amount2=35;
if(amount1>10)
{
if(amount2<100)
{
System.out.println(amount1>amount2?amount1:amount2);
}
}
}
}
we can even write nested if like
if(amount1>10 && amount2<100)
{
if(amount1>amount2)
System.out.println(amount1);
else
System.out.println(amount2);
}

4)
public class Main
{
public static void main(String[] args) {
int x=0,y=15,z=0;
if(x>0)
{
if(y<20)
{
z=1;
}
else
{
z=0;
}
}
System.out.println("x= "+x+" y=
"+y+" z= "+z);
}
}

So, I printed the output for all of them
If you still need anything comment that
I need to run each questions also with the outputs print 1. 3.1 Write an if...
EXERCISES: if & if...else STATEMENTS: Name Examples of if and if-else statements: Write an if statement that multiplies payRate by 1.5 iſ hours is greater than 40. Write variable declarations for the variables payRate and hours first. Hint: Look for keyword if first, your boolean comes after the keyword [. This translates into Java as: double hours, payRate; if (hours > 40) { //{-} are optional here but I recommend that you them payRate = payRate 1.5; pay Rato pay...
Question Five c++ Decision Structures and Boolean Logic 1. Write an if statement that assigns 20 to the variable y and assigns 40 to the variable z if the variable x is greater than 100. 2. Write an if statement that assigns 0 to the variable b and assigns 1 to the variable c if the variable a is less than 10. 3. Write an if-else statement that assigns 0 to the variable b if the variable a is less...
Write a MATLAB program to accomplish the following: Create a variable x by assigning it the value 5. Then, subtract 8 from the square of x and assign the result to a second variable y. Next, create a vector z containing as values all the positive prime integers greater than or equal to 2 and less than 20. Multiply z by two and subtract y, and assign the result to w. ONLY display the value for w in the Command...
Problems: 1. Write a program to define the following variables, assign them values, and print their values on screen: Integer x = 20, Float y = 40.45 Double z = 91.51e+5 Char w = A • • For the integer variable x, you need to print it in decimal notations, octal notations and hexadecimal notation. For the double variable y, you need to print it in double notations and scientific notation. 2. Write a program with the following three parts:...
The following Java code outputs various amounts for a worker based on skill level, hours worked, and insurance: import java.util.Scanner; public class Pay { public static void main(String[] args) { int SkillOneRate = 17; int SkillTwoRate = 20; int SkillThreeRate = 22; double MedicalInsurance = 32.50; double DentalInsurance = 20.00; double DisabilityInsurance = 10.00; int skill,hours; int choice; char y; char n; int payRate =0; double regularPay = 0; double overtimePay = 0; double grossPay=0; double deductions=0; double netPay =...
Question 41 Which of the following is NOT a valid assignment statement? A. x = 55; B. 55 = x; C. x += 3; D. x = 56 + y; Question 42 What is the result of 45 / 4? A. 11.25 B. 10 C. 12 D. 11 Question 43 What is the output of the following code? x = 0; if (x > 0) System.out.println("x is greater than 0"); else if (x < 0) System.out.println("x is less than 0");...
I had a few questions in Computer Science (Java).
I got these questions wrong and I would like the CORRECT answer
and an EXPLANATION PLEASE.
Please use the correct number when giving the answer such as
1a:.
1b:
etc
1. For Each of the following Bits of code enter the final value of the variable names ans. a. int x = 23; int y = 7; Int ans = x % y; My answer 1.61 (Wrong It was 2) b....
5. Write a static method "f(n)" in the space provide, that returns O if n is even, and if n is odd, returns 1 or -1 according as n is greater than or less than 0. importjava.util.Scanner; public class Q_05 Your "f(n)" method: public static void main(String args[]) mana int n; Scanner input = new Scanner(System.in); System.out.print("Please enetrn: "); n=input.nextInt(); System.out.println(f(n)); "Method f(n)" 7. Write a static method "max" in the space provide, that returns the maximum value from 3...
Write a single C++ statements to accomplish each of the following tasks: In one statement, assign the sum of the current value of x and y to z and postincrement the value of x. Determine whether the value of the variable count is greater than 10. If it is, print “Count is greater than 10.”. Pre-decrement the variable of x by 1, then subtract it from the variable total. Multiply variable power by x and assign the result to power. ...
Exercise 1 A program was created that outputs the following unto the console: Hello! What is your name: Hello, Jane Doe! Using this program, we can help you determine you pay for the week! Please enter the hours you worked this week: 20 Next, please enter your rate of pay: 10 Calculating… you will make $ 200 by the end of the week! Here is the code for that program (you should have written a close variant of this last...