Question
Explain how this part of the code works and functions. public class Data { private double percent =0; public Data(int sym, int period,int btemp) {
Explain how this part of the code works and functions.
public class Data { private double percent =0; public Data(int sym, int period,int btemp) { String data = "0 1 36 27.55 0 2 36 28.74 0 3 36 27.55 0 4 36 27.55 0 5 36 27.55 0 6 36 27.55 0 7 36 27.55 1 1 36 27.55 1 2 36 28.74 1 3 36 27.55 1 4 36 27.55 1 5 36 27.55 1 6 36 27.55 1 7 36 27.55 2 1 36 29.66 2 2 36 29.66 2 3 36 29.66 2 4 36 29.66 2 5 36 29.66 2 6 36 29.66 2 7 36 29.66 3 1 36 29.35 3 2 36 29.35 3 3 36 29.35 3 4 36 29.35 3 5 36 29.35 3 6 36 29.35 3 7 36 29.35 4 1 36 29.05 4 2 36 29.05 4 3 36 29.05 4 4 36 29.05 4 5 36 29.05 4 6 36 29.05 4 7 36 29.05 5 1 36 28.74 5 2 36 28.74 5 3 36 28.74 5 4 36 28.74 5 5 36 28.74 5 6 36 28.74 5 7 36 28.74 6 1 36 28.44 6 2 36 28.74 6 3 36 28.44 6 4 36 28.44 6 5 36 28.44 6 6 36 28.44 6 7 36 28.44 7 1 36 28.14 7 2 36 28.74 7 3 36 28.14 7 4 36 28.14 7 5 36 28.14 7 6 36 28.14 7 7 36 28.14 8 1 36 27.84 8 2 36 28.74 8 3 36 27.84 8 4 36 27.84 8 5 36 27.84 8 6 36 27.84 8 7 36 27.84 0 1 37 27.55 0 2 37 28.74 0 3 37 27.55 0 4 37 27.55 0 5 37 27.55 0 6 37 27.55 0 7 37 27.55 1 1 37 27.55 1 2 37 28.74 1 3 37 27.55 1 4 37 27.55 1 5 37 27.55 1 6 37 27.55 1 7 37 27.55 2 1 37 29.66 2 2 37 29.66 2 3 37 29.66 2 4 37 29.66 2 5 37 29.66 2 6 37 29.66 2 7 37 29.66 3 1 37 29.35 3 2 37 29.35 3 3 37 29.35 3 4 37 29.35 3 5 37 29.35 3 6 37 29.35 3 7 37 29.35 4 1 37 29.05 4 2 37 29.05 4 3 37 29.05 4 4 37 29.05 4 5 37 29.05 4 6 37 29.05 4 7 37 29.05 5 1 37 28.74 5 2 37 28.74 5 3 37 28.74 5 4 37 28.74 5 5 37 28.74 5 6 37 28.74 5 7 37 28.74 6 1 37 28.44 6 2 37 28.74 6 3 37 28.44 6 4 37 28.44 6 5 37 28.44 6 6 37 28.44 6 7 37 28.44 7 1 37 28.14 7 2 37 28.74 7 3 37 28.14 7 4 37 28.14 7 5 37 28.14 7 6 37 28.14 7 7 37 28.14 8 1 37 27.84 8 2 37 28.74 8 3 37 27.84 8 4 37 27.84 8 5 37 27.84 8 6 37 27.84 8 7 37 27.84 0 1 38 27.55 0 2 38 28.74 0 3 38 27.55 0 4 38 27.55 0 5 38 27.55 0 6 38 27.55 0 7 38 27.55 1 1 38 27.55 1 2 38 28.74 1 3 38 27.55 1 4 38 27.55 1 5 38 27.55 1 6 38 27.55 1 7 38 27.55 2 1 38 29.66 2 2 38 75.29 2 3 38 75.29 2 4 38 75.29 2 5 38 75.29 2 6 38 75.29 2 7 38 75.29 3 1 38 29.35 3 2 38 75.59 3 3 38 75.59 3 4 38 75.59 3 5 38 75.59 3 6 38 75.59 3 7 38 75.59 4 1 38 29.05 4 2 38 75.90 4 3 38 75.90 4 4 38 75.90 4 5 38 75.90 4 6 38 75.90 4 7 38 75.90 5 1 38 28.74 5 2 38 76.20 5 3 38 76.20 5 4 38 76.20 5 5 38 76.20 5 6 38 76.20 5 7 38 76.20 6 1 38 28.44 6 2 38 76.20 6 3 38 76.50 6 4 38 76.50 6 5 38 76.50 6 6 38 76.50 6 7 38 76.50 7 1 38 28.14 7 2 38 76.20 7 3 38 76.80 7 4 38 76.80 7 5 38 76.80 7 6 38 76.80 7 7 38 76.80 8 1 38 27.84 8 2 38 76.20 8 3 38 77.09 8 4 38 77.09 8 5 38 77.09 8 6 38 77.09 8 7 38 77.09 0 1 39 27.55 0 2 39 28.74 0 3 39 27.55 0 4 39 27.55 0 5 39 27.55 0 6 39 27.55 0 7 39 27.55 1 1 39 27.55 1 2 39 28.74 1 3 39 27.55 1 4 39 27.55 1 5 39 27.55 1 6 39 27.55 1 7 39 27.55 2 1 39 29.66 2 2 39 75.29 2 3 39 75.29 2 4 39 75.29 2 5 39 75.29 2 6 39 75.29 2 7 39 75.29 3 1 39 29.35 3 2 39 75.59 3 3 39 75.59 3 4 39 75.59 3 5 39 75.59 3 6 39 75.59 3 7 39 75.59 4 1 39 29.05 4 2 39 75.90 4 3 39 75.90 4 4 39 75.90 4 5 39 75.90 4 6 39 75.90 4 7 39 75.90 5 1 39 28.74 5 2 39 76.20 5 3 39 76.20 5 4 39 76.20 5 5 39 76.20 5 6 39 76.20 5 7 39 76.20 6 1 39 28.44 6 2 39 76.20 6 3 39 76.50 6 4 39 76.50 6 5 39 76.50 6 6 39 76.50 6 7 39 76.50 7 1 39 28.14 7 2 39 76.20 7 3 39 76.80 7 4 39 76.80 7 5 39 76.80 7 6 39 76.80 7 7 39 76.80 8 1 39 27.84 8 2 39 76.20 8 3 39 77.09 8 4 39 77.09 8 5 39 77.09 8 6 39 77.09 8 7 39 77.09 0 1 40 27.55 0 2 40 28.74 0 3 40 27.55 0 4 40 27.55 0 5 40 27.55 0 6 40 27.55 0 7 40 27.55 1 1 40 27.55 1 2 40 28.74 1 3 40 27.55 1 4 40 27.55 1 5 40 27.55 1 6 40 27.55 1 7 40 27.55 2 1 40 29.66 2 2 40 75.29 2 3 40 75.29 2 4 40 75.29 2 5 40 75.29 2 6 40 75.29 2 7 40 75.29 3 1 40 29.35 3 2 40 75.59 3 3 40 75.59 3 4 40 75.59 3 5 40 75.59 3 6 40 75.59 3 7 40 75.59 4 1 40 29.05 4 2 40 75.90 4 3 40 75.90 4 4 40 75.90 4 5 40 75.90 4 6 40 75.90 4 7 40 75.90 5 1 40 28.74 5 2 40 76.20 5 3 40 76.20 5 4 40 76.20 5 5 40 76.20 5 6 40 76.20 5 7 40 76.20 6 1 40 28.44 6 2 40 76.20 6 3 40 76.50 6 4 40 76.50 6 5 40 76.50 6 6 40 76.50 6 7 40 76.50 7 1 40 28.14 7 2 40 76.20 7 3 40 76.80 7 4 40 76.80 7 5 40 76.80 7 6 40 76.80 7 7 40 76.80 8 1 40 27.84 8 2 40 76.20 8 3 40 77.09 8 4 40 77.09 8 5 40 77.09 8 6 40 77.09 8 7 40 77.09 0 1 41 27.55 0 2 41 28.74 0 3 41 27.55 0 4 41 27.55 0 5 41 27.55 0 6 41 27.55 0 7 41 27.55 1 1 41 27.55 1 2 41 28.74 1 3 41 27.55 1 4 41 27.55 1 5 41 27.55 1 6 41 27.55 1 7 41 27.55 2 1 41 29.66 2 2 41 75.29 2 3 41 75.29 2 4 41 75.29 2 5 41 75.29 2 6 41 75.29 2 7 41 75.29 3 1 41 29.35 3 2 41 75.59 3 3 41 75.59 3 4 41 75.59 3 5 41 75.59 3 6 41 75.59 3 7 41 75.59 4 1 41 29.05 4 2 41 75.90 4 3 41 75.90 4 4 41 75.90 4 5 41 75.90 4 6 41 75.90 4 7 41 75.90 5 1 41 28.74 5 2 41 76.20 5 3 41 76.20 5 4 41 76.20 5 5 41 76.20 5 6 41 76.20 5 7 41 76.20 6 1 41 28.44 6 2 41 76.20 6 3 41 76.50 6 4 41 76.50 6 5 41 76.50 6 6 41 76.50 6 7 41 76.50 7 1 41 28.14 7 2 41 76.20 7 3 41 76.80 7 4 41 76.80 7 5 41 76.80 7 6 41 76.80 7 7 41 76.80 8 1 41 27.84 8 2 41 76.20 8 3 41 77.09 8 4 41 77.09 8 5 41 77.09 8 6 41 77.09 8 7 41 77.09 0 1 42 27.55 0 2 42 28.74 0 3 42 27.55 0 4 42 27.55 0 5 42 27.55 0 6 42 27.55 0 7 42 27.55 1 1 42 27.55 1 2 42 28.74 1 3 42 27.55 1 4 42 27.55 1 5 42 27.55 1 6 42 27.55 1 7 42 27.55 2 1 42 29.66 2 2 42 75.29 2 3 42 75.29 2 4 42 75.29 2 5 42 75.29 2 6 42 75.29 2 7 42 75.29 3 1 42 29.35 3 2 42 75.59 3 3 42 75.59 3 4 42 75.59 3 5 42 75.59 3 6 42 75.59 3 7 42 75.59 4 1 42 29.05 4 2 42 75.90 4 3 42 75.90 4 4 42 75.90 4 5 42 75.90 4 6 42 75.90 4 7 42 75.90 5 1 42 28.74 5 2 42 76.20 5 3 42 76.20 5 4 42 76.20 5 5 42 76.20 5 6 42 76.20 5 7 42 76.20 6 1 42 28.44 6 2 42 76.20 6 3 42 76.50 6 4 42 76.50 6 5 42 76.50 6 6 42 76.50 6 7 42 76.50 7 1 42 28.14 7 2 42 76.20 7 3 42 76.80 7 4 42 76.80 7 5 42 76.80 7 6 42 76.80 7 7 42 76.80 8 1 42 27.84 8 2 42 76.20 8 3 42 77.09 8 4 42 77.09 8 5 42 77.09 8 6 42 77.09 8 7 42 77.09"; String[] wordsArray=data.split(" "); String[]dataInput = new String[1764]; int n=0; for(String word:wordsArray){ dataInput[n]=word; n++; } for(int i=0;i<=dataInput.length-1;i+=4) { if(sym==Integer.valueOf(dataInput[i])&&period==Integer.valueOf(dataInput[i+1])&&btemp==Integer.valueOf(dataInput[i+2])) { percent = Double.valueOf(dataInput[i+3]); } } } public double getPercent() { return percent; } }
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