
Write a program that converts a (C to F Converter from 0 - 20) and writes the output to a file instead of the screen. Open the file in Notepad to confirm the output.

import java.io.*;
import java.util.*;
class TempConverter{
public static void main(String[] args)throws Exception{
Scanner input=new Scanner(System.in);
System.out.print("Enter temperature in C(0-20): ");
double temp=input.nextDouble();
double f=(1.8*temp)+32;
BufferedWriter bw=new BufferedWriter(new FileWriter(new File("C:/temp.txt")));
String fahrenheit=Double.toString(f);
bw.write(fahrenheit);
bw.close();
System.out.println("Temperature is converted.");
}
}

import java.util.Scanner;
public class TempConversion1 { public static void main(String [] args) {
double celsius=0;
while(celsius <= 20)
{
Scanner scan=new Scanner(System.in);
System.out.print("Enter the number in celsius:");
celsius=scan.nextDouble();
System.out.print("farhe:"+(1.8*celsius+32)+"\n");
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.