I have tried many different things trying to get this to work. I am sorry for just a lame question I am a total newbie. When I request information from my inFile does it need to be in the order the data is in?
This is the inData.txt :
10.20 \\\length
5.35 \\\width
15.6 \\\radius
Randy Gill \\\first last name
31 \\\age
18500 \\\bank account balance
3.5 \\\ interest rate
A \\char 'a'
I am supposed to print dimensions of a rectangle, circle. Name with bank account info. Thanks for the help!
import java.util.*;
import java.io.*;
public class ProgrammingExercise3_1
{
public static void main(String[] args) throws FileNotFoundException
{
double rectWidth;
double rectLength;
double radius;
int age;
double begBal;
char A;
String name;
double rate;
Scanner inFile = new Scanner(new FileReader("C:\\Users\\sierr_000\\Desktop\\Sam School\\IT-145\\Exercises\\Ch 3\\inData.txt"));
PrintWriter outFile = new PrintWriter("C:\\Users\\sierr_000\\Desktop\\Sam School\\IT-145\\Exercises\\Ch 3\\outData.out");
rectWidth = inFile.nextDouble();
rectLength = inFile.nextDouble();
outFile.println("Rectangle: ");
outFile.println("Length = " + rectLength + ", width = " + rectWidth + ", area = "
+ (rectWidth*rectLength) + ", perimeter = " + (2 * (rectWidth + rectLength)));
radius = inFile.nextDouble();
outFile.println("Circle: ");
outFile.println("Radius = " + radius + ", area = " + (radius*3.1416) + "Circumfrence = " + (2*3.1416*radius));
name = inFile.next();
age = inFile.nextInt();
outFile.println("Name: " + name + ", age: " + age);
begBal = inFile.nextDouble();
rate = inFile.nextDouble();
outFile.printf("Beginning Balance: %.2f %n" , begBal + "interest rate: %.2f" , rate);
outFile.println("The character that comes after A in the ASCII is B");
inFile.close();
outFile.close();
}
}