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
Lelu [443]
3 years ago
12

The following program uses a variable workHoursPerWeek rather than directly using 40 in the salary calculation expression.

Computers and Technology
1 answer:
Serjik [45]3 years ago
7 0

Answer:

<u> Initial program output (from original program)</u>

Annual salary is: 40000

Monthly salary is: 3333

<u>Program output after workHoursPerWeek = 35</u>

Annual salary is: 35000

Monthly salary is: 2916

<u>Revised program (using variable workWeeksPerYear)</u>

  1.    public static void main(String[] args) {
  2.        int hourlyWage = 20;
  3.        int workHoursPerWeek = 35;
  4.        int workWeeksPerYear = 52;
  5.        int annualSalary = 0;
  6.        annualSalary = hourlyWage * workHoursPerWeek * workWeeksPerYear;
  7.        System.out.print("Annual salary is: ");
  8.        System.out.println(annualSalary);
  9.        System.out.print("Monthly salary is: ");
  10.        System.out.println((hourlyWage * workHoursPerWeek * workWeeksPerYear) / 12);
  11.        return;
  12.    }

Program output:

Annual salary is: 36400

Monthly salary is: 3033

<u>Revised Program after introducing monthly salary</u>

  1.    public static void main(String[] args) {
  2.        int hourlyWage = 20;
  3.        int workHoursPerWeek = 35;
  4.        int workWeeksPerYear = 52;
  5.        int annualSalary = 0;
  6.        int monthlySalary = 0;
  7.        
  8.        annualSalary = hourlyWage * workHoursPerWeek * workWeeksPerYear;
  9.        monthlySalary = hourlyWage * workHoursPerWeek * workWeeksPerYear;
  10.        
  11.        System.out.print("Annual salary is: ");
  12.        System.out.println(annualSalary);
  13.        System.out.print("Monthly salary is: ");
  14.        System.out.println((monthlySalary) / 12);
  15.        return;
  16.    }

Explanation:

One reason to use variable to replace the magic number is to improve the readability of the program. If we compared the revised version of the program with the original program, we will find that the variable enable our code easier to understand.

Besides, if we wish to change the value (e.g. working hours per year or per month), we just need to adjust the value assigned on the variables. The variables provide a single access point to get or change the value.

You might be interested in
When correctly implemented, what is the only cryptosystem known to be unbreakable?
Leona [35]

When accurately executed, the only cryptosystem known to be unbreakable is called: "One-time Pad" (Option D)

<h3>What is a Crypto System?</h3>

The one-time pad is a cryptographic approach that cannot be broken but needs the usage of a single-use pre-shared key that is not less than the message being delivered. A plaintext is coupled with a unique secret key in this manner.

It should be emphasized that in cryptography, a cryptosystem is a collection of cryptographic algorithms that are required to perform a certain security function, such as confidentiality. A cryptosystem is often composed of three algorithms: one just for key generation, one for encrypting, and one for deciphering.

Learn more about Crypto System:
brainly.com/question/15084188
#SPJ1

Full Question:

When correctly implemented, what is the only cryptosystem known to be unbreakable?

A) Transposition cipher

B) Substitution cipher

C) Advanced Encryption Standard

D) One-time Pad

6 0
1 year ago
A student is helping a friend with a home computer that can no longer access the Internet. Upon investigation, the student disco
Firlakuza [10]

Answer:

Option (D) is the right answer.

Explanation:

DHCP term used as a short form of dynamic host configuration protocol, which is used to assigns the IP address automatically according to the network.

According to the scenario, the system is getting the wrong IP address that resulting in internet disconnection which is a failure of the DHCP server because it is responsible for assigning the right IP address to the system.

Hence option (D) is the most appropriate answer.

While other options are wrong because of the following reasons:

  • Static IP is the type of IP address which is fix and doesn't change in the system after rebooting, hence it has no connection in the change of IP address.
  • If the DHCP server is working well there is no chance of interference from the surrounding device.
  • Network setting has no connection with computer power supply as SMPS is used to give power and boot system only.
8 0
4 years ago
Which of the following is not an advantage of a dbms?
vovikov84 [41]
I looked it up and A seems to be it
7 0
3 years ago
Read 2 more answers
Need Help Please
erastova [34]

Answer:

1. siblings + 1

2. numberOfPizzas * pizzaCost

3. alienGreeting + alienGreeting2

4. color1 === color2

5. value1 - value2

6. console.log(gradeAverage === gradeAverage2)

7. numberToString + numberToString2

8. numberOfStudents / numberOfClassrooms

9. console.log(carSpeed === truckSpeed)

4 0
3 years ago
Each high-level language has its own __________, or rules of the language. group of answer choices
il63 [147K]

Each high-level language has its own syntax which is also called rules of the programming language. Therefore, the correct choice is syntax.

High-level languages have a greater level of abstraction from details of the computer. They focus more on the programming logic which is closely associated with human understanding instead of the underlying hardware modules. Each high-level programming language has its own specific set of rules which is known as the syntax of that language.

Syntax of the high-level languages define structure and formation of the statements in the language. In order to write a program in any high-level programming language, proper syntax of that programming language requires to be followed.

If the syntax of the programming language is not followed properly, the compiler will produce errors. In result, required output of the program will not be generated because of the failure of the program execution.

You can learn more about syntax at

brainly.com/question/831003

#SPJ4

5 0
2 years ago
Other questions:
  • Imagine you are writing a personal fitness program that stores the user's age, gender, height (in feet or meters), and weight (t
    10·1 answer
  • Exercise 3: Function Write a function named word_count that accepts a string as its parameter and returns the number of words in
    10·1 answer
  • Given two variables hasToner and hasPaper of type bool, that have been declared and given values, write a code block that will o
    15·1 answer
  • What is the full form of ICT?​
    14·2 answers
  • The results of the SPEC CPU2006 bzip2 benchmark running on an AMD Barcelona has an instruction count of 2.389E12, an execution t
    6·1 answer
  • Made from fruit juice, water and sugar, The American version contains milk and cream and sometimes egg white​
    9·1 answer
  • What is used to print out very large posters or maps?
    10·2 answers
  • THE DIFFERENCE BETWEEN COPY AND PASTE AND CUT AND PASTE IS: *
    5·2 answers
  • what is the keyboard shortcut to display formulas on the worksheet : a. CTRL+ B. CTRL+: C. CTRL+; D. ALL THE ABOVE
    10·1 answer
  • Which tool can you use to display hardware utilization statistics that tell you about the operation of your computer?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!