Question

In: Computer Science

. Assume that a double variable named alpha contains the value of an angle in radians....

. Assume that a double variable named alpha contains the value of an angle in radians. Compose a C++ statement that will display the sine of the angle so that it occupies 12 positions on the screen and displays 3 digits after the decimal point.

Solutions

Expert Solution

#include <iostream>

#include<cmath>

#include <iomanip>

int main() {

//delcaring variavel to store radians

double alpha = 20;

std::cout << "OUTPUT: \n\n";

//fixing the precision of the floating value.

std::cout.precision(3);

//setw(int n) is used to give a width of n spaces.

//setfill(char c) is used to fill the remaing spaces by charcater c.

std::cout << std::setfill (' ') << std::setw (12); //setting width of 12 charcater spaces in the line

std::cout << sin(alpha); //printing this value, all remaing spaces before this will be filled by setfill().

}

IF THERE IS ANYTHING THAT YOU DO NOT UNDERSTAND, OR NEED MORE HELP THEN P-LEASE MENTIN IT IN THE COMMENTS SECTION,


Related Solutions

Write a class named GasTank containing: An instance variable named amount of type double, initialized to...
Write a class named GasTank containing: An instance variable named amount of type double, initialized to 0. An instance variable named capacity of type double. A constructor that accepts a parameter of type double. The value of the parameter is used to initialize the value of capacity. A method named addGas that accepts a parameter of type double. The value of the amount instance variable is increased by the value of the parameter. However, if the value of amount is...
1. Assume that total has already been declared as a double variable and received a value,...
1. Assume that total has already been declared as a double variable and received a value, and discountRate has been declared as a double variable, you don’t need to declare them again. You write one if statement (not multiple individual if statements) for following requirements. when total is less than 50, set discountRate to 0.0; when total is equal to or greater than 50 and less than 100, set discountRate to 0.05; when total is equal to or greater than...
Define a class named Document that contains an instance variable of type String named text that...
Define a class named Document that contains an instance variable of type String named text that stores any textual content for the document. Create a method named toString that returns the text field and also include a method to set this value. Next, define a class for Email that is derived from Document and includes instance variables for the sender, recipient, and title of an email message. Implement appropriate set and get methods. The body of the email message should...
C++ 3a)Assume you have an integer pointer variable named intpoint2. It contains the address 1e6f24. You...
C++ 3a)Assume you have an integer pointer variable named intpoint2. It contains the address 1e6f24. You execute intpoint2++. What does intpoint2 now contain? a)1e6f24 b)1e6f25 c)1e6f28 d)1e6f2c 3b)You have an array of integers: int myints[10]; and the address of the first integer is be4350. What is the address of myints[1]? myints[2]?You have an array of integers: int myints[10]; and the address of the first integer is be4350. What is the address of myints[1]? myints[2]? a)Both are b34350 b)be4350 and b34354...
The function Sine is defined as: where x is an angle in radians Write a Matlab...
The function Sine is defined as: where x is an angle in radians Write a Matlab script program to compute the sinus value of any angle as the following: - The program should run always until the user enters - 1 to exit from the program. - A sk user to enter: Number of elements (N) that should be included in the sum - C heck that N is a positive integer . [ Hint: use ( round (N) -...
Write a program that asks the user for an angle, entered in radians. The program should...
Write a program that asks the user for an angle, entered in radians. The program should then display the sine, cosine, and tangent of the angle. (Use the sin, cos, and tan library functions to determine these values.) The output should be displayed in fixed-point notation, rounded to four decimal places of precision Take your previous Angle Calculator program and modify it to do a table of trig values. The columns will be: Degrees, Sine, Cosine, Tangent,. And the rows...
Find the angle θ between the vectors in radians and in degrees. u = cos π...
Find the angle θ between the vectors in radians and in degrees. u = cos π 3 i + sin π 3 j, v = cos 3π 4 i + sin 3π 4 j (a) radians (b) degrees
java Define the Circle2D class that contains: • Two double data fields named x and y...
java Define the Circle2D class that contains: • Two double data fields named x and y that specify the center of the circle with get methods. A data field radius with a get method. • A data field radius with a get method. • A no-arg constructor that creates a default circle with (0, 0) for (x, y) and 1 for radius. • A constructor that creates a circle with the specified x, y, and radius. • A method getArea()...
Define the circle2d class that contains: Two double data fields named x and y that specify...
Define the circle2d class that contains: Two double data fields named x and y that specify the center of the circle with getter methods A data field radius with a getter method A no arg constructor that creates a default circle with 0,0 for x,y and 1 for the radius A constructor that creates a circle with the specified x,y of the the circle A method getArea() that returns the area of the circle A method Contains(Double x, Double y)...
In Java, design a class named MyInteger. The class contains: An int data field named value...
In Java, design a class named MyInteger. The class contains: An int data field named value that stores the int value represented by this object. A constructor that creates a MyInteger object for the specified int A get method that returns the int Methods isEven(), isOdd(), and isPrime() that return true if the value is even, odd, or prime, respectively. Static methods isEven(int), isOdd(int), and isPrime(int) that return true if the specified value is even, odd, or prime, respectively. Static...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT