Question
I need help being able to call the method from ScientificNot to the Main class then displaying to output. Thanks. class Main { public static
I need help being able to call the method from ScientificNot to the Main class then displaying to output. Thanks.
class Main {
public static void main(String[] args) {
ScientificNot scinumber = new ScientificNot("31536000", 1);
System.out.println(scinumber);
}
}
class ScientificNot {
char decimal = '.';
String value;
int prec;
public ScientificNot() {
value = "";
prec = 0;
}
public ScientificNot(String value, int prec) {
this.value = value;
this.prec = prec;
}
public String getValue() {
return value;
}
public ScientificNot convertSci(String value, int prec) {
if (prec == 0) {
value = value.charAt(0) + value.substring(1, prec + 1) + "E"
+ value.substring(prec, value.substring(0).length()).length();
if (prec == 1) {
value = (value.charAt(0) + value.substring(1, 1) + decimal + value.substring(1, prec + 1) + "E"
+ value.substring(1, value.substring(0).length()).length());
if (value.length() < prec) {
prec = value.length();
value = (value.charAt(0) + value.substring(1, 1) + decimal + value.substring(1, prec + 1) + "E"
+ value.substring(1, value.substring(0).length()).length());
}
}
}
}
public String toString() {
return value + "," + prec;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started