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
polet [3.4K]
3 years ago
9

Write assignment statements that perform the following operations with the variables a, b, and c. i. Adds 2 to ‘a’ and assigns t

he result to ‘b’. ii. Multiplies ‘b’ times 4 and assigns the result to ‘a’. iii. Divides ‘a’ by 3.14 and assigns the result to ‘b’. iv. Subtracts 8 from ‘b’ and assigns the result to ‘a’.
Computers and Technology
1 answer:
solniwko [45]3 years ago
3 0
<h2>Answer: </h2>

(i) b = a + 2;

(ii) a = b * 4;

(iii) b = a / 3.14;

(iv) a = b - 8;

<h2>Explanation: </h2><h3>Assumptions and comments; </h3>

=> The code has been written in Java.

=> The variable a, b and c have been declared.

=> The variable c has only been declared but not used since it is not part of the assignment procedures.

<h3>Explanation: </h3>

The following is the assignment statement that;

<em>(i) Adds 2 to ‘a’ and assigns the result to ‘b’</em>

To add a number to another number or variable, the arithmetic operator (+) is used using the following syntax;

[number] [+] [other number]

In our case, the number is variable a and the other number is 2. Therefore, to add these numbers together we write;

a + 2;

Also, assignment in programming languages is done using the (=) operator. For example to assign a number k to a variable m, we write;

m = k

In our case, the result (a + 2) from above is assigned to variable b as follows;

=> b = a + 2

<em>(ii) Multiplies ‘b’ times 4 and assigns the result to ‘a’.</em>

To multiply a number by another number or variable, the arithmetic operator (*) is used using the following syntax;

[number] [*] [other number]

In our case, the number is variable b and the other number is 4. Therefore, to multiply these numbers we write;

b * 4;

Also,

In our case, the result (b * 4) from above is assigned to variable a as follows;

=> a = b * 4

<em>(iii) Divides ‘a’ by 3.14 and assigns the result to ‘b’.</em>

To divide a number by another number or variable, the arithmetic operator (/) is used using the following syntax;

[number] [/] [other number]

In our case, the number is variable a and the other number is 3.14. Therefore, to divide these numbers we write;

a / 3.14;

Also,

In our case, the result (a / 3.14) from above is assigned to variable b as follows;

=> b = a / 3.14

<em>(iv) Subtracts 8 from ‘b’ and assigns the result to ‘a’.</em>

To subtract a number from another number or variable, the arithmetic operator (-) is used using the following syntax;

[other number] [-] [number]

In our case, the number is 8 and the other variable is b. Therefore, to subtract these numbers we write;

b - 8;

Also,

In our case, the result (b - 8) from above is assigned to variable a as follows;

=> a = b - 8;

You might be interested in
What is the decimal number 75 in binary and hexadecimal?
hammer [34]

Answer:

00110111 00110101-Binary

3735-Hex

8 0
3 years ago
Use the drop-down menus to complete the statements about using column breaks in word 2016
Naily [24]

Answer: Breaks in the word 2016 what do you mean

Explanation:

7 0
3 years ago
Read 2 more answers
In this lab, you use the flowchart and pseudocode found in the figures below to add code to a partially created C++ program. Whe
never [62]

Answer:

The equivalent program in C++:

#include<iostream>

#include <sstream>

using namespace std;

int main(){

   string Score, Rank;

   cout<<"Enter student score and class rank: ";

   cin>>Score>>Rank;

   int testScore = 0, classRank = 0;

   stringstream sstream(Score);

   sstream>>testScore;

   

   stringstream tream(Rank);

   tream>>classRank;

   

   if (testScore >= 90){

       if(classRank >=25){cout<<"Accept";}

       else{cout<<"Reject";}

   }

   else if(testScore >= 80){

       if(classRank >=50){cout<<"Accept";}

       else{cout<<"Reject";}

   }

   else if(testScore >= 70){

       if(classRank >=75){cout<<"Accept";}

       else{cout<<"Reject";}

   }

   else{cout<<"Reject";}

   return 0;

}

Explanation:

This declares Score and Rank as string variables

   string Score, Rank;

This prompts the user for score and class rank

   cout<<"Enter student score and class rank: ";

This gets the user input

   cin>>Score>>Rank;

This declarees testScore and classRank as integer; and also initializes them to 0

   int testScore = 0, classRank = 0;

The following converts string Score to integer testScore

<em>    stringstream sstream(Score);</em>

<em>    sstream>>testScore;</em>

The following converts string Rank to integer classRank

   stringstream tream(Rank);

   tream>>classRank;

The following conditions implement the conditions as given in the question.    

If testScore >= 90

<em>    if (testScore >= 90){</em>

If classRank >=25

<em>        if(classRank >=25){cout<<"Accept";}</em>

If otherwise

<em>        else{cout<<"Reject";}</em>

<em>    } ---</em>

If testScore >= 80

<em>    else if(testScore >= 80){</em>

If classRank >=50

<em>        if(classRank >=50){cout<<"Accept";}</em>

If otherwise

<em>        else{cout<<"Reject";}</em>

<em>    }</em>

If testScore >= 70

<em>    else if(testScore >= 70){</em>

If classRank >=75

<em>        if(classRank >=75){cout<<"Accept";}</em>

If otherwise

<em>        else{cout<<"Reject";}</em>

<em>    }</em>

For testScore less than 70

<em>    else{cout<<"Reject";}</em>

<em />

3 0
3 years ago
Convert the following numbers. (Please show all steps; no marks will be awarded if no steps are shown) [1.5 x 4 = 6 marks]
katen-ka-za [31]

Answer:

i. 10210212

ii. 100 101 001 in BASE 2

iii. 46.4631

iv. 12.453125

Explanation:

i. Converting to base 10 we get

=  10 x 162 + 13 x 161 + 9 x 160 = 2777

Converting to base 10 we get  =

2777/3 = 925 with remainder 2

925/3 = 308 with remainder 1

308/3 = 102 with remainder 2

102/3 = 34 with remainder 0

34/3 = 11 with remainder 1

11/3 = 3 with remainder 2

3/3 = 1 with remainder 0

1/3 = 0 with remainder 1

Hence the Answer is 10210212

ii. = Octal is taken in pair of 3 bits , Writing binary of each number in 3 bits we get  = 100 101 001 in BASE 2

iii. = 1 x 52 + 2 x 51 + 3 x 50 + 3 x 5-1   = 38.6 in decimal

Converting to Octal we get

38 /8 = 4 with remainder 6

4 /8 = 0 with remainder 4

.6 x 8 =  4.8

.8 x 8 = 6.4

46.4631

iv. = 1x 81 + 4 x 80 + 3 x 8-1 + 5 x 8-2   = 12.453125

Check here for Free courses about IT and Management www.eacademy.lk

4 0
3 years ago
What does FIFO mean?
zubka84 [21]
Hello there!

It is First In First Out

Hope This Helps You!
Good Luck :)
6 0
3 years ago
Read 2 more answers
Other questions:
  • You want to discard your old computer and want to securely erase the data from your hard drive. What can you use to do this and
    6·1 answer
  • What is the internet?
    5·2 answers
  • What tabs found in the Windows Task Manager dialog box
    7·1 answer
  • You are building a gaming computer and you want to install a dedicated graphics card that has a fast gpu and 1gb of memory onboa
    15·2 answers
  • What is application software? A computer language for accessing data in a database. A character string used to identify the loca
    10·1 answer
  • Credible sites contain __________ information,
    7·2 answers
  • There is a renewed focus among today’s parents on providing food to their family.
    6·1 answer
  • you are packing a mobile phone containing a lithium ion battery and you get a prompt on the screen to put a lithium ion label on
    13·1 answer
  • photoshop Curves, photoshop an image and manipulate the curves on a selection of the photo. upload the original photo and The ph
    5·2 answers
  • Select the correct answer
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!