[Code on SoloLearn Part 1][Code on SoloLearn Part 2]1[My Take Home Assignment [][1]2` [Radians, Tangent, Sine, Cosine, and Degrees Table
import java.util.Scanner;
public class St_Johns_University
{
public static void main(String[] args) {
System.out.printf("%-10s%-10s%-10s%-10s%-10s\n", "Radians", "Tangent", "Sine", "Cosine", "Degrees");
int degrees = 60;
double radians = Math.toRadians(degrees);
System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4f\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 80;
radians = Math.toRadians(degrees);
System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4f\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 100;
radians = Math.toRadians(degrees);
System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4f\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 130;
radians = Math.toRadians(degrees);
System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4f\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 160;
radians = Math.toRadians(degrees);
System.out.printf("%-10d%-10.4f%-10.4f%-10.4f%-10.4f\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
}
}
`
Your formatting using print f is wrong. Also import of Scanner is not required.
degree is int but you have provided f
instead of d
and also provided precision 4. radians is double. but you have provided d
which is wrong
I have corrected it please check the below code.
public class St_Johns_University
{
public static void main(String[] args) {
System.out.printf("%-10s%-10s%-10s%-10s%-10s\n", "Radians", "Tangent", "Sine", "Cosine", "Degrees");
int degrees = 60;
double radians = Math.toRadians(degrees);
System.out.printf("%-10f%-10.4f%-10.4f%-10.4f%-10d\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 80;
radians = Math.toRadians(degrees);
System.out.printf("%-10f%-10.4f%-10.4f%-10.4f%-10d\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 100;
radians = Math.toRadians(degrees);
System.out.printf("%-10f%-10.4f%-10.4f%-10.4f%-10d\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 130;
radians = Math.toRadians(degrees);
System.out.printf("%-10f%-10.4f%-10.4f%-10.4f%-10d\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
degrees = 160;
radians = Math.toRadians(degrees);
System.out.printf("%-10f%-10.4f%-10.4f%-10.4f%-10d\n", radians, Math.tan(radians), Math.sin(radians), Math.cos(radians), degrees);
}
}