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

Define a function named sumsinconv that accepts double precision variable theta, double precision variable alpha, and...
Define a function named sumsinconv that accepts double precision variable theta, double precision variable alpha, and unsigned integer n, and returns the solution of expression sin ⁡ ( ( n + 1 ) α 2 ) sin ⁡ ( θ + n α 2 ) sin ⁡ ( α 2 ) in C Only show the function definition. Do not write an entire program with a main function. Just write the definition for function sumsinconv.
Java Implement a class MyInteger that contains: • An int data field/instance variable named value that...
Java Implement a class MyInteger that contains: • An int data field/instance variable named value that stores the int value represented by this object. • A constructor that creates a MyInteger object for a default int value. What default value did you choose? What other values did you consider? Why did you make this choice? • A constructor that creates a MyInteger object for a specified int value. • A getter method, valueOf(), that returns value. • A setter method,...
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...
10. We are trying to assign the value of a variable named “FirstNumber” to a variable...
10. We are trying to assign the value of a variable named “FirstNumber” to a variable named “SecondNumber”. They are declared as shown below. Which of the following statements is correct? double FirstNumber = 25.5; int SecondNumber; Group of answer choices c. SecondNumber = int.Parse (FirstNumber); b. SecondNumber = (double) FirstNumber; d. SecondNumber = double.Parse (FirstNumber); a. SecondNumber = (int)FirstNumber;
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT