Answer: Hey dear student finds the solution of your query if you have any doubt feel free to ask. Thanks!!
1- Java Code
int num,num1,num2;
if(num>100)
{
num1 = 20;
num2 = 40;
}
2- Java Program TimeCalculator
import java.io.*;
import java.util.Scanner; //import packages
class TimeCalculator
{
public static void main(String []args)
{
int seconds,leftover = 0,minutes = 0; //variable declarations
Scanner sc = new Scanner(System.in); //Scanner object
System.out.println("enter number of seconds: ");
seconds = sc.nextInt(); //takes input for seconds from user
if(seconds>=60) //check if seconds greater than or equalto
60
{
minutes = seconds/60; //to get minutes
leftover = seconds%60; //to get seconds
}
System.out.println("Minutes: "+minutes); //print minutes
System.out.println("Leftover seconds: "+leftover); //print
leftover
}
}
3- Java Code
int varX,varY;
if(varY>150)
{
varX= 5;
}
else
{
varX = 10;
}
4- Java code
int num1,num2,num3;
if(num1<10)
{
num2 = 0;
num3 = 1;
}
else
{
num2 = -99;
num3 = 0;
}
5- Java program
import java.io.*;
import java.util.Scanner;
class Main
{
public static void main(String []args)
{
int length1,length2,width1,width2;
int area1,area2;
area1 = length1*width1;
area2 = length2*width2;
if(area1>area2)
{
System.out.println("Rectangle1 is greater");
}
else
{
System.out.println("Rectangle2 is greater");
}
}
}
EXERCISES: if & if...else STATEMENTS: Name Examples of if and if-else statements: Write an if statement...
Assignment #1: Write a C++ Program. Consider the following program segment. // Name: Your Name // MU ID: Your ID // include statement (s) l using namespace statement int main() //variable declaration //executable statements // return statement a. Include the header files isotream. b. Include cin, cout, and endl. c. Declare two variables: numi, num2, num3, and average of type int. d. Assign 125 into numi, 28 into num2, and -25 into num3 e. Store the average of numi, num2,...
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...
This is Visual Basics... Write an if/else statement that assigns true to the variable fever if the variable temperature is greater than 98.6; otherwise it assigns false to fever.* Write an if/else statement that adds 1 to the variable minors if the variable age is less than 18, adds 1 to the variable adults if age is 18 through 64 and adds 1 to the variable seniors if age is 65 or older.*
I need to run each questions also with the outputs print 1. 3.1 Write an if statement that assigns 0 to x when y is equal to 20. If (y == 20) X=0; 2. 3.2 Write an if statement that multiplies payRate by 1.5 if hours is greater than 40. If (hours > 40) payRate - payRate * 1.5; 3. 3.12 Write nested if statements that perform the following test: If amounti is greater than 10 and amount 2 is...
Topics If/Else statement Description Write a program that determines the larger of the two numbers provided by the user. The program asks the user to enter a number. Then it asks the user to enter another but a different number. Then, it determines the larger of the two numbers and displays it to the user. (If the user happens to enter the two numbers the same, the program may report either of the two numbers as larger.) Requirements Do...
1. Write a statement that calls a function named showSquare, passing the value 10 as an argument. 2. Write the function prototype for a function called showSquare. The function should have a single parameter variable of the int data type and areturn type of void. 3. Write the function prototype for a function called showScoreswith a parameter list containing four integer variables and a return type of void. 4. Look at the following function definition: double getGrossPay(int hoursWorked, double payRate)...
Small aircraft weight limit Write an if-else statement that assigns safetyCheck with 1 if the sum of passengerWeight and cargoWeight is less than or equal maxWeight. Otherwise, assign safetyCheck with 0. Ex: If passengerWeight is 200, cargoWeight is 100, and maxWeight is 500, then safetyCheck is assigned with 1. If passengerWeight is 300, cargoWeight is 275, and maxWeight is 500, then safetyCheck is assigned with 0. Function Save C Reset DI MATLAB Documentation 1 function safetyCheck = CargoLimit(passengerWeight, cargoweight) 2...
Write a C++ program that uses: .selection constructs (if, if else, and switch) .multiway branches .looping constructs (do and while loops) .Boolean expressions, bool and char types. 1. Develop a program that calculates charges for an Internet provider. The cost is determined by the amount of data used and the consumer plan. Package B (basic) is the most affordable if you plan on using < 20GB (20,000MB), however, if you consume more than 20GB (20,000MB) you are charged for each...
Use only if else nested if else only otherwise your answer won't be entertained. Problem 1(b): Write a program that gives remainder without using modulus operator and loops. The first number entered will be dividend and second number entered will be divisor. Sample input: 15 6 Sample output: Remainder is 3 In a right triangle, the square of the length of one side is equal to the sum of the squares of the length of the other two sides. Write...
JAVA PROGRAM USING ECLIPSE. THE FIRST IMAGE IS THE INSTRUCTIONS, THE SECOND IS THE OUTPUT TEST CASES(WHAT IM TRYING TO PRODUCE) BELOW THOSE IMAGES ARE THE .JAVA FILES THAT I HAVE CREATED. THESE ARE GeometircObject.Java,Point.java, and Tester.Java. I just need help making the Rectangle.java and Rectangle2D.java classes. GeometricObject.Java: public abstract class GeometricObject { private String color = "white"; // shape color private boolean filled; // fill status protected GeometricObject() { // POST: default shape is unfilled blue this.color = "blue";...