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
Java languageThe cost to ship a package is a flat fee of 75 cents plus 25 cents per pound.1. Declare a constant named CENTS_PER_
Sophie [7]

Answer:

// Here is code in Java.

// import package

import java.util.*;

// class definition

class Main

{

   // main method of the class

public static void main (String[] args) throws java.lang.Exception

{

    try{

   // variables

    final int CENTS_PER_POUND = 25;

    final int FLAT_FEE_CENTS = 75;

    // Scanner object to read input

   Scanner sr=new Scanner(System.in);

   System.out.print("Enter the shipping weight:");

   // read the input weight

   int shipWeightPounds=sr.nextInt();

   // calculate total cost

  int shipCostCents = (shipWeightPounds * CENTS_PER_POUND) + FLAT_FEE_CENTS;

  // print Weight

  System.out.println("shipping  Weight: " + shipWeightPounds);

  // print flat fee

     System.out.println("flat fee of shipping in cents : " + FLAT_FEE_CENTS);

     // print cents per round

     System.out.println("Cents/pound for shipping: " + CENTS_PER_POUND);

     // print cost of Shipping

    System.out.println("total cost of shipping in cents: " + shipCostCents);

   

   

   }catch(Exception ex){

       return;}

}

}

Explanation:

Declare and initialize two constant variables "CENTS_PER_POUND=25" & "FLAT_FEE_CENTS = 75". Read the input weight from user with the help of Scanner class object. Then  calculate the cost of shipping by multiply weight with cent per pound and add flat fee. Then print each of them.

Output:

Enter the shipping weight:12                                                                                                                                  

shipping  Weight : 12                                                                                                                                        

flat fee of shipping in cents: 75                                                                                                                              

Cents/pound for shipping: 25                                                                                                                                  

total cost of shipping in cents: 375  

8 0
1 year ago
Read 2 more answers
assume that name is a variable of type stirng that has been assigned a value write an expression whose value is the last charact
Snezhnost [94]

Answer:

The most straight forward way to do it: in general string are zero index based array of characters, so you need to get the length of the string, subtract one and that will be the last character, some expressions in concrete languages would be:

In Python:

name = "blair"

name[len(name) - 1]

In JavaScript:

name = "blair"

name[name.length - 1]

In C++:

#include <string>

string name = "blair";

name[name.length() - 1];

7 0
1 year ago
The it department is reporting that a company web server is receiving an abnormally high number of web page requests from differ
Talja [164]
<span>In the scenario in which the IT department is reporting that a company web server is receiving an abnormally high number of web page requests from different locations simultaneously the DDoS security attack is occurring.
</span>DDos stands for Distributed Denial of Service<span> . This </span><span>attack is an attempt to make an online service unavailable by overwhelming it with traffic from multiple sources.</span>
8 0
1 year ago
Create a program named Auction that allows a user to enter an amount bid on an online auction item. Include three overloaded met
Olin [163]

Answer:

Explanation:

The following code is written in Java and creates the overloaded methods as requested. It has been tested and is working without bugs. The test cases are shown in the first red square within the main method and the output results are shown in the bottom red square...

class Auction {

   public static void main(String[] args) {

       bid(10);

       bid(10.00);

       bid("10 dollars");

       bid("$10");

       bid("150 bills");

   }

   public static void bid(int bid) {

       if(bid >= 10) {

           System.out.println("Bid Accepted");

       } else {

           System.out.println("Bid not high enough");

       }

   }

   public static void bid(double bid) {

       if(bid >= 10) {

           System.out.println("Bid Accepted");

       } else {

           System.out.println("Bid not high enough");

       }

   }

   public static void bid(String bid) {

       if (bid.charAt(0) == '$') {

           if (Integer.parseInt(bid.substring(1, bid.length())) > 0) {

               System.out.println("Bid Accepted");

               return;

           } else {

               System.out.println("Bid not in correct Format");

               return;

           }

       }

       int dollarStartingPoint = 0;

       for (int x = 0; x < bid.length(); x++) {

           if (bid.charAt(x) == 'd') {

               if (bid.substring(x, x + 7).equals("dollars")) {

                   dollarStartingPoint = x;

               } else {

                   break;

               }

           }

       }

       if (dollarStartingPoint > 1) {

           if (Integer.parseInt(bid.substring(0, dollarStartingPoint-1)) > 0) {

               System.out.println("Bid Accepted");

               return;

           } else {

               System.out.println("Bid not in correct format");

               return;

           }

       } else {

           System.out.println("Bid not in correct format");

           return;

       }

   }

}

3 0
1 year ago
To keep from overwriting existing fields with your Lookup you can use the ____________ clause.
Radda [10]
I believe the answer is <span>outputnew
</span>The main difference between the output new and the output is that outputnew won't overrite the alredy existing description field.
If you don't put this clause, <span>Splunk would adds all the field names and values to your events by through the lookup.</span>
3 0
2 years ago
Read 2 more answers
Other questions:
  • A large department store has been attaching tags with barcodes to merchandise, and employees use barcode readers to scan merchan
    14·2 answers
  • 3. Of the following pieces of information in a document, for which would you most likely insert a mail merge field? A. First nam
    13·2 answers
  • What is the major function of the network access layer?
    5·1 answer
  • What technique creates different hashes for the same password? ccna routing protocols final answers?
    7·1 answer
  • Within a word processing program, predesigned files that have layout and some page elements already completed are called text bo
    15·1 answer
  • 1. The precious metals needed to make computer chips, graphic cards, and transistors are found in only a small population of cou
    8·1 answer
  • Which option in the Caption dialog box configures whether the caption appears above or below the image
    11·2 answers
  • Why is it important for element IDs to have meaningful names?
    11·1 answer
  • 1-(50 points) The function sum_n_avgcomputes the sum and the average of three input arguments and relays its results through two
    8·1 answer
  • Which characteristic of Cloud computing allows data centers to better manage hard drive failures and allocate computing resource
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!