1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
NARA [144]
3 years ago
6

Assume that a boolean variable workedOvertime has been declared, and that another variable, hoursWorked has been declared and in

itialized. Write a statement that assigns the value true to workedOvertime if hoursWorked is greater than 40 and false otherwise.
Computers and Technology
1 answer:
meriva3 years ago
8 0

Answer:

The c++ program to show the use of Boolean variable is given below.

#include <iostream>

using namespace std;  

int main() {    

  int hoursWorked = 44;

   bool workedOvertime;        

   cout<<"This program shows the use of boolean variable." <<endl;    

   // overtime refers to working hours more than 40 hours

   if(hoursWorked > 40)

   {

       workedOvertime = true;

       cout<<"The value of boolean variable workedOvertime is true or "<<workedOvertime<<endl;

   }

   // if working hours are less than or equal to 40, overtime is not considered        

   else

   {

       workedOvertime = false;

       cout<<"The value of boolean variable workedOvertime is false or "<<workedOvertime<<endl;

   }

   return 0;

}  

OUTPUT

This program shows the use of boolean variable.

The value of boolean variable workedOvertime is true or 1  

Explanation:

This program uses a boolean variable to indicate the overtime of working hours.

The boolean variable is declared as shown.

bool workedOvertime;  

The working hours is stored in an integer variable which is declared and initialized within the program itself.

int hoursWorked = 44;

Depending on the value of working hours, the boolean variable is assigned the value true or false.  

if(hoursWorked > 40)

   {

       workedOvertime = true;

       cout<<"The value of boolean variable workedOvertime is true or "<<workedOvertime<<endl;

   }

else

   {

       workedOvertime = false;

       cout<<"The value of boolean variable workedOvertime is false or "<<workedOvertime<<endl;

   }

The value of boolean variable is displayed to the user.

In the above program, the working hours are 44 which is more than normal working hours of 40. Hence, boolean variable is assigned value true.

This program does not accept user input for working hours as stated in the question. Since value of working hours is not accepted from the user, there is no logic implemented to check the validity of the input.

This program can be tested for different values of working hours to test for the boolean variable.

You might be interested in
Why should programmers use a Post Mortem Review?
Zina [86]
The goal of a postmortem is to draw meaningful conclusions to help you learn from your past successes and failures. Despite its grim-sounding name, a postmortem can be an extremely productive method of improving your development practices.
8 0
4 years ago
Hallo! Was ist die Hauptstadt von Northdakote wirklich schätzen, wenn jemand gefragt
timama [110]

Hallo!

I'm thinking you're speaking German so I'm gonna translate


Die Hauptstadt von North Dakota ist Bismark. Hoffe das hilft! Ich wünsche ihnen einen wunderbaren Tag!



~CoCo

5 0
3 years ago
Read 2 more answers
Fill in the code to complete the following method for checking whether a string is a palindrome. public static boolean isPalindr
Ilia_Sergeevich [38]

Answer:

(s.charAt(0) != s.charAt(s.length()-1))

Explanation:

public class Palindrome

{

public static void main(String[] args) {

   

    System.out.println(isPalindrome("car"));

    System.out.println(isPalindrome("carac"));

 

}

   public static boolean isPalindrome(String s) {

       if (s.length() <= 1)

           return true;

       else if (s.charAt(0) != s.charAt(s.length()-1))

           return false;

       else

           return isPalindrome(s.substring(1, s.length() - 1));

   }

}

You may see the whole code above with two test scenarios.

The part that needs to be filled is the base case that if the character at position 0 is not equal to the character at the last position in the string, that means the string is not a palindrome. (If this condition meets, it checks for the second and the one before the last position, and keeps checking)

4 0
4 years ago
What type of adventure/puzzle computer games can I download and not have to pay for? Some games that I've played are Legend of Z
Y_Kistochka [10]

Answer: Pirate and wizard 101, also try using an emulator for a certain console like NES to play certain games you can think of that are available on that console.

5 0
3 years ago
Read 2 more answers
Best company who provides the best ISP (internet service provider)?
valina [46]

Answer:

Explanation:

all internet service providers are garbage. especially in america.

so i will focus on only the positives about one. even though  i know a bunch of bad things about this one.

AT&T is super innovative in that they are bringing fiber optic to many homes in America. Fiber optic is a new type of wiring that brings the fastest Internet never seen before, at speeds of one gigabit per second or even more. Furthermore, their technicians tend to resolve any issues with routers at home.

5 0
2 years ago
Other questions:
  • The ________ model allows the owner of a resource to manage who can or cannot access the item. Owners maintain this access throu
    8·1 answer
  • How can you best utilize CSS for Web Development?
    6·1 answer
  • Many shops are simply plugging up their drains to keep from inadvertently violating the law and creating environmental contamina
    15·1 answer
  • what would happen if a large number of computer users are attempting to access a web site at the same time that you are
    15·2 answers
  • "when a dynamic web page is requested, the web server passes the request to"
    15·1 answer
  • A chiropractor is looking at the Security Standards Matrix and believes that it is unnecessary to address the encryption and dec
    8·1 answer
  • You wrote a program to allow to guess a number chosen randomly.
    10·2 answers
  • Edhesive assignment 1 movie ratings
    9·1 answer
  • 4.1 code practice python
    13·1 answer
  • 3. Find the best.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!