answer.
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]
1 year 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:
meriva1 year 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
Adele’s mother owns a Daycare and she wants to learn all about this business, to help her mom and own it one day. Which CTSO sho
Gennadij [26K]

Answer:

She should join the Future Business Leaders of America–Phi Beta Lambda

Explanation:

CTSOs are Career and technical student organizations. These organizations are vocational and extracurricular groups based primarily in high schools, colleges and career technological centres, for students in Career and Technical Education. They are important parts of the high school and college programs.

The Future Business Leaders of America–Phi Beta Lambda prepares students to become community-minded business leaders. It provides opportunities to learn career skills and gain leadership experience.

Therefore Adele should pick this CTSO

7 0
2 years ago
A bicycle sharing company is developing a multi-tier architecture to track the location of its bicycles during peak operating ho
fgiga [73]

Answer:

d use Amazon API Gateway with Amazon kinesis...

5 0
1 year ago
Write any 5 activities that help to remove bad events from the society?​
vova2212 [387]

Answer:

1. Awareness program

2. Education

3. women empowerment

6 0
1 year ago
Read 2 more answers
Which of the following is a collection of unprocessed items, which can include text, numbers, images, audio, and video?A. DataB.
Tema [17]

Answer:

Option A is the correct answer for the above question.

Explanation:

Data can be defined as raw fact which can be useful when it will be processed. The processed data can be formed as information. The data can be anything. It can b e text or audio or images or video. The above question asked about the term which is an unprocessed item and can form information after processing. Then the answer is Data which stated from the option A. So Option A is the correct answer while the other is not because--

  • Option B states about instruction which is useful to process the data.
  • Option C states about Programs that can be formed when one or more instruction is grouped.
  • Option D states about the information that the user can get after processed the data.

6 0
2 years ago
Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A
harina [27]

Answer:

se explaination

Explanation:

//Design a class named Person

public class Person

{

//A person has a name, address, phone number, and email address.

String name;

String address;

String phone;

String email;

//Constructor with arguments

public Person(String pname,String paddress,String phNum,String pemail)

{

name=pname;

address=paddress;

phone=phNum;

email=pemail;

}

// toString() method to return the name

public String toString()

{

return getClass().getName()+" "+name;

}

}

---------------------------------------------------------

//Student.java

public class Student extends Person

{

//A student has a class status

//(freshman,sophomore, junior, or senior).

//Define the status as a constant.

final int freshman =1;

final int sophomore =2;

final int junior=3;

final int senior=4;

String status="freshman";

//Constructor with arguments

public Student(String name, String address,String phonenumber, String email, int Status)

{

super(name,address,phonenumber,email);

if(Status == 1)

{

status = "freshman";

}

if(Status == 2)

{

status = "sophomore";

}

if(Status == 3)

{

status = "junior";

}

if(Status == 4)

{

status = "Senior";

}

status = "Student";

}

public String toString()

{

return super.toString() + " " + status;

}

}

------------------------------------------------------

//Employee.java

public class Employee extends Person

{

//An employee has an office, salary, and date hired.

String office;

double salary;

java.util.Date dateHired;

//Constructor with arguments

public Employee(String name,String address,String phonenumber,String email,String off,double sal)

{

super(name,address,phonenumber,email);

office=off;

salary=sal;

}

public String toString()

{

return (super.toString() + " " + office +" " + salary);

}

}

--------------------------------------------------------

//Faculty.java

public class Faculty extends Employee

{

//A faculty member has office hours and a rank.

String officeHours;

String rank;

//Constructor with arguments

public Faculty(String name,String address,String phonenumber,String email,String off,int salary,String offHours,String ranks)

{

super(name,address,phonenumber,email,off,salary);

officeHours=offHours;

rank=ranks;

}

public String toString()

{

return (super.toString() + " " + officeHours +" " + rank);

}

}

-----------------------------------------------------------------------------

//Staff.java

public class Staff extends Employee

{

//A staff member has a title

String title;

//Constructor with arguments

public Staff(String name,String address,String phonenumber,String email,String off,int salary,String ti t)

{

super(name,address,phonenumber,email,off,salary);

title=ti t;

}

public String toString()

{

return (super.toString() + " " + title);

}

}

3 0
2 years ago
Other questions:
  • A U.S. social security number consists of a string of 9 digits, such as "444422333". Assume that input consists of a sequence of
    6·2 answers
  • Write a algorithm to attend birthday party​
    8·2 answers
  • Select the correct answer. James is a sales analyst of a departmental store chain. He checked the sale records for the past 12 m
    6·2 answers
  • What three requirements are defined by the protocols used in network communications to allow message transmission across a netwo
    11·1 answer
  • Item = "quesadilla"
    7·1 answer
  • Recall the problem of finding the number of inversions. As in the text, we are given a sequence of n numbers a1, . . . , an, whi
    8·1 answer
  • A computer with a 240-watt power supply is connected to a 120 V circuit and is left on continuously for one month (31 days). How
    9·1 answer
  • Which of the following has been a result of the increase in local organic farms?a decrease in farmers' markets
    10·2 answers
  • A shop will give discount of 10% if the cost of purchased quantity is more than 1000. Ask user for quantity suppose, one unit wi
    15·1 answer
  • When authenticating a user's password, the password supplied by the user is authenticated by comparing the ____ of the password
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!