Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need to make a program using the scanner class that outputs F to C 32f-212 and 0

ID: 3798385 • Letter: N

Question

Need to make a program using the scanner class that outputs F to C 32f-212 and 0c-100c. Do i need to use a for loop? Please help thanks

A table needs to be made

Faren. Celsius

--------------------

32.00 | 0.00

ect | ect

212.00 | 100.00

-----------------------

output should look something like that

2 El import java util. Scanner public class Temp public static void main (String args) Scanner input new Scanner System in) double celsius, fahrenheit; 10 System out print Enter a temperature in Fahrenheit fahrenheit input .next Double 12 celsius (fahrenheit 32) 5 9; 14 System out println. I fahrenheit I celsius "I") for 17 18 20 21 22 23 Output X Tempo (run x Temp (run) #2 x Enter a temperature in Fahrenheit: 32 I 32.0 0.0 I BUILD SUCCESSFUL (total time: 4 seconds

Explanation / Answer

package org.students;

import java.text.DecimalFormat;
import java.util.Scanner;

public class FahrenheitToCelsius {

   public static void main(String[] args) {
       //Declaring variable
       double tCelsius;
       int tFah;
       //DecimalFormat class is used to format the output
               DecimalFormat df=new DecimalFormat("#.##");
              
               //Scanner object is used to get the inputs entered by the user
               Scanner sc=new Scanner(System.in);
               System.out.print("Enter temperature(in Fahrenheit) :");
               tFah=sc.nextInt();
       System.out.println(" Faren.|Celsius");
       System.out.println("----------------");
      
       /* this for loop will convert the Fahrenheit to celsius
       * and display in tabular format
       */
       for(tFah=32;tFah<=212;tFah++)
       {
           tCelsius=(tFah-32)*(5.0/9.0);
           System.out.println(tFah+" | "+df.format(tCelsius));
       }
       System.out.println("----------------");
   }

}

___________________

Output:

Enter temperature(in Fahrenheit) :32

Faren.|Celsius
----------------
32 | 0
33 | 0.56
34 | 1.11
35 | 1.67
36 | 2.22
37 | 2.78
38 | 3.33
39 | 3.89
40 | 4.44
41 | 5
42 | 5.56
43 | 6.11
44 | 6.67
45 | 7.22
46 | 7.78
47 | 8.33
48 | 8.89
49 | 9.44
50 | 10
51 | 10.56
52 | 11.11
53 | 11.67
54 | 12.22
55 | 12.78
56 | 13.33
57 | 13.89
58 | 14.44
59 | 15
60 | 15.56
61 | 16.11
62 | 16.67
63 | 17.22
64 | 17.78
65 | 18.33
66 | 18.89
67 | 19.44
68 | 20
69 | 20.56
70 | 21.11
71 | 21.67
72 | 22.22
73 | 22.78
74 | 23.33
75 | 23.89
76 | 24.44
77 | 25
78 | 25.56
79 | 26.11
80 | 26.67
81 | 27.22
82 | 27.78
83 | 28.33
84 | 28.89
85 | 29.44
86 | 30
87 | 30.56
88 | 31.11
89 | 31.67
90 | 32.22
91 | 32.78
92 | 33.33
93 | 33.89
94 | 34.44
95 | 35
96 | 35.56
97 | 36.11
98 | 36.67
99 | 37.22
100 | 37.78
101 | 38.33
102 | 38.89
103 | 39.44
104 | 40
105 | 40.56
106 | 41.11
107 | 41.67
108 | 42.22
109 | 42.78
110 | 43.33
111 | 43.89
112 | 44.44
113 | 45
114 | 45.56
115 | 46.11
116 | 46.67
117 | 47.22
118 | 47.78
119 | 48.33
120 | 48.89
121 | 49.44
122 | 50
123 | 50.56
124 | 51.11
125 | 51.67
126 | 52.22
127 | 52.78
128 | 53.33
129 | 53.89
130 | 54.44
131 | 55
132 | 55.56
133 | 56.11
134 | 56.67
135 | 57.22
136 | 57.78
137 | 58.33
138 | 58.89
139 | 59.44
140 | 60
141 | 60.56
142 | 61.11
143 | 61.67
144 | 62.22
145 | 62.78
146 | 63.33
147 | 63.89
148 | 64.44
149 | 65
150 | 65.56
151 | 66.11
152 | 66.67
153 | 67.22
154 | 67.78
155 | 68.33
156 | 68.89
157 | 69.44
158 | 70
159 | 70.56
160 | 71.11
161 | 71.67
162 | 72.22
163 | 72.78
164 | 73.33
165 | 73.89
166 | 74.44
167 | 75
168 | 75.56
169 | 76.11
170 | 76.67
171 | 77.22
172 | 77.78
173 | 78.33
174 | 78.89
175 | 79.44
176 | 80
177 | 80.56
178 | 81.11
179 | 81.67
180 | 82.22
181 | 82.78
182 | 83.33
183 | 83.89
184 | 84.44
185 | 85
186 | 85.56
187 | 86.11
188 | 86.67
189 | 87.22
190 | 87.78
191 | 88.33
192 | 88.89
193 | 89.44
194 | 90
195 | 90.56
196 | 91.11
197 | 91.67
198 | 92.22
199 | 92.78
200 | 93.33
201 | 93.89
202 | 94.44
203 | 95
204 | 95.56
205 | 96.11
206 | 96.67
207 | 97.22
208 | 97.78
209 | 98.33
210 | 98.89
211 | 99.44
212 | 100
----------------

___________Thank You

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote