Question

write an if statement that sets the variable hours to 10 when Boolean flag variable minimum...

write an if statement that sets the variable hours to 10 when Boolean flag variable minimum is equal to true.

(I would like to have this shown as a full fledge program pls) THANK YOU!!!!!

Homework Answers

Answer #1

if (minimum == true)

hours=10;

Program to set number of hours based on minimum value.

Program:

public class MyClass {
  
//Main method
public static void main(String args[]) {
  
//Variable to store hours of type integer   
int hours;
  
//Varible to store minimum of type boolean
boolean minimum;
  
//Initialising minimum. If this value is toggled, output changes.
minimum = false;

  
if (minimum == true)
hours=10;
else
hours=20;
  
System.out.println("Hours: "+hours);
  
}
}

Sample Output:

Hours: 20

Know the answer?
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
Similar Questions
If and else statements: 1a.) Given the following declaration: int temperature; Write an if statement that...
If and else statements: 1a.) Given the following declaration: int temperature; Write an if statement that prints the message "The number is valid" if the variable temperature is within the range of -50 trough 150 (both values excluded). 1b.) Given the following declarations int x; int y; Write an if statement that assigns 100 to x when y is equal to 0. 1c.) Given the following declaration: int grade; Write an if statement that prints the message "The number is...
Goal is a variable of type int. Write an If-Else statement the outputs the word “WOW”...
Goal is a variable of type int. Write an If-Else statement the outputs the word “WOW” if the value of goal is greater than 10 and the word “OH WELL” if the value is less than 10. There are two variables goal and error of type int. Write an output statement “WOW” if the value of goal is greater than 10 and value of error is zero. Otherwise it displays “Oh Well”. Write a Java program which can print the...
How do you write a genetic algorithm to find a minimum value? When the minimum value...
How do you write a genetic algorithm to find a minimum value? When the minimum value is between -5 and 5 for all variables/dials? solution would look like this 0.0 -2.549550887309249 0.35704557166422424 etc Fitness 1 is: 167.8344671475403
The following Excel output represents an attempt to determine if the two sets of data (Variable...
The following Excel output represents an attempt to determine if the two sets of data (Variable 1 and Variable 2) have equal variances. Based on the information shown would you accept the hypothesis of equal variances? You must show how you came to your conclusion Variable 1 Variable 2 Mean 2.21 2.01 Variance 2.95 3.58 Observations 20 20 df 19 19 F 0.82 P(F<=f) one-tail 0.04 F Critical one-tail 0.46
I am trying to write an if-else statement in Java with 7 different variables, initialized and...
I am trying to write an if-else statement in Java with 7 different variables, initialized and declared as integers. I want to write an if-else statement that says "You win!" if their sum equals 21, but says "Sum does not equal 21, exiting program." otherwise. If the sum does not equal 21, then I would need to close the keyboard as well.
Bash script with branching and looping Part 1: 1. Create a variable called NAME and set...
Bash script with branching and looping Part 1: 1. Create a variable called NAME and set it equal to the empty string (NAME=””). Create a variable called NAME_LENGTH and set it equal to the length of your last name. Output the value of the NAME variable to show that it is empty. 2. Write a FOR loop that executes as many times as there are letters in your name (use the NAME_LENGTH variable in your condition). Use a CASE statement...
1. Write a statement that assigns an empty list to the variable named empty. 2. Write...
1. Write a statement that assigns an empty list to the variable named empty. 2. Write a statement which assigns all the odd integer values between 0 and 10 (in order) to the variable named odds. 3. Write a statement which assigns the list of three-letter abbreviations of the months of the year to the variable months. That would be: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Capitalize correctly and have no punctuation. 4. Create...
For table shown in figure 1 construct (a) a Boolean expression having the given table as...
For table shown in figure 1 construct (a) a Boolean expression having the given table as its truth table and (b) a circuit having the given table as its input/output table. (10 points) Figure 1: Truth table 6. Find the Boolean expressions for the circuits in figure 2 and show that they are logically equivalent when regarded as statement forms.(16 points) Figure 2: Circuits 7. Let R(m, n) be the predicate “If m is a factor of n 2 then...
Write a SQL update statement that changes the grade for student 4456 who passed the course...
Write a SQL update statement that changes the grade for student 4456 who passed the course Discrete Math in semester 2017Sp. Change the grade from C to B.   For full credit you should have a single update statement that has a where clause that verifies that the current grade is C. Use ap as the Schema Table to find your answer whoevr is solving this problem thank you. heres wht i needu to do. Thge question is the bold part...
   QUESTION 6 1.   If we wanted something like the python else statement for a counter...
   QUESTION 6 1.   If we wanted something like the python else statement for a counter controlled loop in Java, what would it look like?        Since there is no way for a loop in Java to tell you if it completed without breaks or continues, you'd need to set a boolean flag to indicate that and check it after the loop was completed.        We simply check either break or continue flags to see if either is...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT