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
PIT_PIT [208]
3 years ago
12

(Rounding Numbers) An application of function floor is rounding a value to the nearest

Computers and Technology
1 answer:
Whitepunk [10]3 years ago
7 0

Answer:

Following are the program in the C++ Programming Language.

//header file

#include <iostream>

//header file for floor function

#include<math.h>

//using namespace

using namespace std;

//define main function

int main() {

 //set and initialize float type variable and value

 float a=12.3, c=1.45, d=165.345;

 //initialize it in other variable

 float x=a;

 //set float variable to store floor value

 float y=floor(x+5);

 //display output with message

 cout<<"before "<<x<<" and after the floor "<<y<<endl;

 //set float variable to store floor value

 y=floor(c+5);

 //display output with message

 cout<<"before "<<c<<" and after the floor "<<y<<endl;

 //set float variable to store floor value

 y=floor(d+5);

 //display output with message

 cout<<"before "<<d<<" and after the floor "<<y;

}

Output:

before 12.3 and after the floor 17

before 1.45 and after the floor 6

before 165.345 and after the floor 170

Explanation:

Here, we define the "main()" function and inside the main function.

  • Set and initialize three float data type variables "a", "c", "d" to 12.3, 1.45, 165.345.
  • Set the float data type variable "x" to store the value of the variable "a"
  • Again set float type variable "y" to store the floor value.
  • Then, Print message and output of the variable.
  • Again we repeat point 3 and 4 two times.
You might be interested in
Determine the following information about each value in a list of positive integers.
german

Answer and Explanation:

Using Javascript:

test7_11_13(num){

If(num%7===0||num%11===0||num%13===0){

Console.log("yes it is a multiple of 7,11 or 13");

}

else{

Console.log("It is not a multiple of any of the numbers");

}

function(num){

var makeString= num.toString();

var splitString= makeString.split("");

var makeNumber= splitString.map(Number());

var New_number= makeNumber.reduce(function(a, b) {

return a+b};,0)

}

If(New_number%2===0){

Console.log("it's an even number");

}

else{

Console.log("it's an odd number")

}

If(num%2===0||num%3===0||num%5===0||num%7===0||num%11===0){

console.log("it's not a prime number");

}

else{

console.log("it's a prime number");

}

}

From the above we have used javascript if..else statements to test the conditions for each question and output the answer to the console using console.log(). In the last part for prime number, you could also choose to use else if statements(if,else if, else if) to test the value of the num parameter and output if it's a prime number.

8 0
3 years ago
What kind of device is a printer? output or input
ANEK [815]
A printer is output. :)
8 0
2 years ago
TV show information can either keep track of the number of viewers per show or the name of a show. Information is kept in a file
Elza [17]

Answer:

See explaination for Program source code.

Explanation:

The program source code below.

#include <iostream>

#include <fstream>

#include <vector>

using namespace std;

class Show

{

private:

string title;

int viewers;

public:

Show()

{

this->title = "";

this->viewers = 0;

}

Show(string title, int viewers)

{

this->title = title;

this->viewers = viewers;

}

string getTitle(){ return this->title; }

int getViewers(){ return this->viewers; }

};

int main()

{

vector<Show> shows;

vector<string> titles;

vector<int> viewers;

ifstream inFile1("file1.txt");

ifstream inFile2("file2.txt");

string line1, line2;

if(!inFile1.is_open() || !inFile2.is_open())

{

cout << "Either of the files could not be found!\n";

exit(0);

}

getline(inFile1, line1);

if(line1.compare("Show") == 0)

{

while(getline(inFile1, line1))

{

titles.push_back(line1);

}

inFile1.close();

}

getline(inFile2, line2);

if(line2.compare("Viewer") == 0)

{

while(getline(inFile2, line2))

{

viewers.push_back(stod(line2));

}

inFile2.close();

}

for(int i = 0; i < titles.size(); i++)

{

shows.push_back(Show(titles[i], viewers[i]));

}

// display all the show details

cout << "\nALL SHOWS:\n----------\n";

for(Show show : shows)

{

cout << "Title: " << show.getTitle() << ", Number of viewers: " << show.getViewers() << endl;

}

cout << endl;

return 0;

}

See attachment for output

3 0
3 years ago
Mica's creating his web page with a software that is free of charge for the first month. If he likes the program, he will have t
Katarina [22]
The answer is C. Shareware
4 0
3 years ago
Read 2 more answers
What four things does steering control involve?
Dafna1 [17]

Answer:

putting your hands one the wheel, putting the car in gear, putting your foot on the brakes when you need to, and watch for cars when you're driving. hope it helps

Explanation:

7 0
3 years ago
Other questions:
  • Which of the following takes place during the research phase
    7·1 answer
  • What is the safest way to install a new flash drive
    7·2 answers
  • Which statement about images is correct? A) A virtual image cannot be formed on a screen. B) A virtual image cannot be viewed by
    12·1 answer
  • How do you know if your phone has a virus?
    13·1 answer
  • A browser is used for creating Web pages. true or false?
    5·2 answers
  • What is the web of trust
    7·2 answers
  • Were does igneous rocks cool?
    9·1 answer
  • Write a function called prod_all that takes any number of arguments and returns their sum. Test the function by using these two
    10·1 answer
  • ---------------------- use of the Internet to access programs and data on computers that are not owned and managed by the user o
    9·1 answer
  • What type of error occurred with the code below??
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!