Ask coding questions

← Back to all posts
1
Making A File
DemonLord1 (0)

import java.util.Scanner;//did not work
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;

public class ReadAndWrite {

public static void main(String [] args) 
		throws FileNotFoundException {
	
	Scanner diskScanner = new Scanner(new File("rawData.txt"));
	
	PrintStream diskWriter = new PrintStream("vita.txt");
	double unitPrice, quantity,total;
	
	unitPrice = diskScanner.nextDouble();
	quantity = diskScanner.nextInt();
	
	total = unitPrice * quantity;
	diskWriter.println(total);
	
	diskScanner.close();
	diskWriter.close();
		
}

}

Commentshotnewtop
1
ash15khng (220)

Hi, to help others trying to answer your question, could you include a repl link and what problems you're facing?