THE CORRECT OUTPUT OF THE TEST CASE THE CORRECT OUTPUT OF THE TEST CASE 1.00000 1 sin(0) 0.00000 %3D 21 22 sin(95) = 0.99619 23 sin(100) = 0.98481 24 sin(105) 25 sin(110) 26 sin(115) = 0.90631 27 sin(120) 3 sin(5) 4 sin(10) 5 sin(15) 0.25882 6 sin(20) 7 sin(25) 8 sin(30) 9 sin(35) 10 sin(40) sin(45) 12 sin(50) 13 sin(55) 14 sin(60) 15 sin(65) 16 sin(70) = 0.08716 = 0.17365 0.96593 = 0.93969 = 0.34202 = 0.42262 = 0.86603 28 sin(125) = 0.81915 29 sin(130) 30 sin(135) 31 sin(140) 32 sin(145) 33 sin(150) 34 sin(155) 35 sin(160) 36 sin(165) = 0.25882 = 0.50000 = 0.76605 = 0.70711 = 0.64279 = 0.57358 = 0.50000 = 0.42262 = 0.34202 = 0.57358 = 0.64279 = 0.70711 = 0.76604 = 0.81915 = 0.86602 = 0.90631 = 0.93969 11 UNIX DIFE: OF CORRECT QUTPUT AND YOUR QUTPUT THE CORRECT OUTPUT OF THE TEST CASE THE CORRECT OUTPUT OF THE TEST CASE 40 -0.90595 41 sin(185) = -0.08715 63 sin(290) 64 sin(295) 65 sin(300) 66 sin(305) 67 sin(310) 68 sin(315) 69 sin(320) 70 sin(325) 71 sin(330) 72 sin(335) 73 sin(340) 74 sin(345) 75 sin(350) 76 sin(355) 77 sin(360) = -0.93969 = -0.90631 = -0.86603 = -0.81915 = -0.76605 = -0.70711 = -0.64279 = -0.57358 = -0.50000 = -0.42262 = -0.34202 = -0.25882 42 sin(19e) = -0.17365 = -0.25882 = -0.34202 = -0.42262 = -0.50000 = -0.57357 = -0.64279 sin(195) 44 sin(200) 43 sin(205) 46 sin(210) 47 sin(215) 48 sin(220) 49 sin(225) 45 -0.70710 = -0.76604 sin(230) 51 sin(235) sin(240) = -0.86602 53 sin(245) 54 sin(250) 55 sin(255) 56 sin(260) 50 -0.81915 52 = -0.90631 = -0.93969 = -0.96592 = -0.17365 = -0.08716 -0.00001 -0.98481 78 YOUR CODE'S OUTPUT 1 Enter the value in degree: In radians 2. = 0.00000 a 7 The sine value of e = 0.0000 8 The sine value of 5 = 0.08716 9 The sine value of 10 = 0.17365 = 0.25882 0.34202 0.42262 11 The sine value of 20 12 The sine value of 25 13 The sine value of 30 14 The sine value of 35 15 The sine value of 40 16 The sine value of 45 = 0.50000 0.57358 0.64279 0.70711

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

So I am getting an error when I submit my c++ code. The prompt for the hw was as follows:

Create 2 functions:
1) Degrees2Radians: which has input Degrees, and returns Radians
2) Drawline: which takes two parameters: a character and numRepetitions and prints the character numRepetitions times, followed by a newline
 
Inside main()
For values between 0 and 360, in 5 degree increments:
calculate and print the value of sin (degrees),
After every 90 degrees, print out a line of 30 dashes (minus signs '-')

Extra information required:

#include <cmath> // for sin function


In order to have the precise format we want:
Put this at the top of main:

cout.setf(ios::fixed);
cout.setf(ios::showpoint); // show decimals even if not needed
cout.precision(5); // show 5 digits to right of decimal

 

My code:

#include <iostream>

#include <cmath>

using namespace std;

 

int i, j; // to iterate the loop

const double PI = 3.141592; // value of a pi

 

// this function will convert the degrees into radians

double Degrees2Radians()

{

int degree; // user input for degree

double radian; // to store the value of radians

 

// input from the user

cout << "Enter the value in degree: ";

cin >> degree;

 

// converting degrees into radians

radian = degree * (PI / 180);

 

// display the result

cout << "In radians = " << radian << endl;

return radian;

}

 

// this function will show the character numRepetitions times

void Drawline(char a, int numRepetitions)

{

// in this loop, character is displayed numRepetitions times

for (i = 1; i <= numRepetitions; i++)

cout << a << endl;

}

 

int main(void)

{

cout.setf(ios::fixed);

cout.setf(ios::showpoint);

cout.precision(5);

 

// calling the functions

Degrees2Radians();

Drawline('a', 5);

 

double radian; // to store the value of radians

 

// in this loop, the values for radians is

// displayed, after every 5 degrees

for (i = 0; i <= 360; i = i + 5)

{

// converting degrees into radians

radian = i * (PI / 180);

 

// display The result

cout << "The sine value of " << i << " = " << sin(radian) << endl;

 

// in this if, a line of 30 dashes will be

// displayed, after every 90 degree

if (i % 90 == 0 && i > 0)

{

for (j = 0; j <= 30; j++)

cout << "-";

cout << endl;

}

}

}

Below I have posted the error I receive. So, in order for the test to pass it needs to match exactly with the correct code output. 

THE CORRECT OUTPUT OF THE TEST CASE
THE CORRECT OUTPUT OF THE TEST CASE
1.00000
1 sin(0)
0.00000
%3D
21
22 sin(95) = 0.99619
23 sin(100) = 0.98481
24 sin(105)
25 sin(110)
26 sin(115) = 0.90631
27 sin(120)
3 sin(5)
4 sin(10)
5 sin(15) 0.25882
6 sin(20)
7 sin(25)
8 sin(30)
9 sin(35)
10 sin(40)
sin(45)
12 sin(50)
13 sin(55)
14 sin(60)
15 sin(65)
16 sin(70)
= 0.08716
= 0.17365
0.96593
= 0.93969
= 0.34202
= 0.42262
= 0.86603
28 sin(125) = 0.81915
29 sin(130)
30 sin(135)
31 sin(140)
32 sin(145)
33 sin(150)
34 sin(155)
35 sin(160)
36 sin(165) = 0.25882
= 0.50000
= 0.76605
= 0.70711
= 0.64279
= 0.57358
= 0.50000
= 0.42262
= 0.34202
= 0.57358
= 0.64279
= 0.70711
= 0.76604
= 0.81915
= 0.86602
= 0.90631
= 0.93969
11
UNIX DIFE: OF CORRECT QUTPUT AND YOUR QUTPUT
THE CORRECT OUTPUT OF THE TEST CASE
THE CORRECT OUTPUT OF THE TEST CASE
40
-0.90595
41 sin(185)
= -0.08715
63 sin(290)
64 sin(295)
65 sin(300)
66 sin(305)
67 sin(310)
68 sin(315)
69 sin(320)
70 sin(325)
71 sin(330)
72 sin(335)
73 sin(340)
74 sin(345)
75 sin(350)
76 sin(355)
77 sin(360)
= -0.93969
= -0.90631
= -0.86603
= -0.81915
= -0.76605
= -0.70711
= -0.64279
= -0.57358
= -0.50000
= -0.42262
= -0.34202
= -0.25882
42 sin(19e) = -0.17365
= -0.25882
= -0.34202
= -0.42262
= -0.50000
= -0.57357
= -0.64279
sin(195)
44 sin(200)
43
sin(205)
46 sin(210)
47 sin(215)
48 sin(220)
49 sin(225)
45
-0.70710
= -0.76604
sin(230)
51 sin(235)
sin(240) = -0.86602
53 sin(245)
54 sin(250)
55 sin(255)
56 sin(260)
50
-0.81915
52
= -0.90631
= -0.93969
= -0.96592
= -0.17365
= -0.08716
-0.00001
-0.98481
78
Transcribed Image Text:THE CORRECT OUTPUT OF THE TEST CASE THE CORRECT OUTPUT OF THE TEST CASE 1.00000 1 sin(0) 0.00000 %3D 21 22 sin(95) = 0.99619 23 sin(100) = 0.98481 24 sin(105) 25 sin(110) 26 sin(115) = 0.90631 27 sin(120) 3 sin(5) 4 sin(10) 5 sin(15) 0.25882 6 sin(20) 7 sin(25) 8 sin(30) 9 sin(35) 10 sin(40) sin(45) 12 sin(50) 13 sin(55) 14 sin(60) 15 sin(65) 16 sin(70) = 0.08716 = 0.17365 0.96593 = 0.93969 = 0.34202 = 0.42262 = 0.86603 28 sin(125) = 0.81915 29 sin(130) 30 sin(135) 31 sin(140) 32 sin(145) 33 sin(150) 34 sin(155) 35 sin(160) 36 sin(165) = 0.25882 = 0.50000 = 0.76605 = 0.70711 = 0.64279 = 0.57358 = 0.50000 = 0.42262 = 0.34202 = 0.57358 = 0.64279 = 0.70711 = 0.76604 = 0.81915 = 0.86602 = 0.90631 = 0.93969 11 UNIX DIFE: OF CORRECT QUTPUT AND YOUR QUTPUT THE CORRECT OUTPUT OF THE TEST CASE THE CORRECT OUTPUT OF THE TEST CASE 40 -0.90595 41 sin(185) = -0.08715 63 sin(290) 64 sin(295) 65 sin(300) 66 sin(305) 67 sin(310) 68 sin(315) 69 sin(320) 70 sin(325) 71 sin(330) 72 sin(335) 73 sin(340) 74 sin(345) 75 sin(350) 76 sin(355) 77 sin(360) = -0.93969 = -0.90631 = -0.86603 = -0.81915 = -0.76605 = -0.70711 = -0.64279 = -0.57358 = -0.50000 = -0.42262 = -0.34202 = -0.25882 42 sin(19e) = -0.17365 = -0.25882 = -0.34202 = -0.42262 = -0.50000 = -0.57357 = -0.64279 sin(195) 44 sin(200) 43 sin(205) 46 sin(210) 47 sin(215) 48 sin(220) 49 sin(225) 45 -0.70710 = -0.76604 sin(230) 51 sin(235) sin(240) = -0.86602 53 sin(245) 54 sin(250) 55 sin(255) 56 sin(260) 50 -0.81915 52 = -0.90631 = -0.93969 = -0.96592 = -0.17365 = -0.08716 -0.00001 -0.98481 78
YOUR CODE'S OUTPUT
1 Enter the value in degree: In radians
2.
= 0.00000
a
7 The sine value of e = 0.0000
8 The sine value of 5 = 0.08716
9 The sine value of 10 = 0.17365
= 0.25882
0.34202
0.42262
11 The sine value of 20
12 The sine value of 25
13 The sine value of 30
14 The sine value of 35
15 The sine value of 40
16 The sine value of 45
= 0.50000
0.57358
0.64279
0.70711
Transcribed Image Text:YOUR CODE'S OUTPUT 1 Enter the value in degree: In radians 2. = 0.00000 a 7 The sine value of e = 0.0000 8 The sine value of 5 = 0.08716 9 The sine value of 10 = 0.17365 = 0.25882 0.34202 0.42262 11 The sine value of 20 12 The sine value of 25 13 The sine value of 30 14 The sine value of 35 15 The sine value of 40 16 The sine value of 45 = 0.50000 0.57358 0.64279 0.70711
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education