All pastes #168422 Raw Edit

Ravi

public java v1 · immutable
·published 2006-09-12 23:39 UTC
rendered paste body
9/12/2006Honor Pledge-I have neither given nor received unauthorized aid on this program.Purpose: To create an in-depth questionaire that determines how students travel to campus*****************************************************************************************/import javax.swing.JOptionPane;import java.io.PrintWriter;import java.io.*;import java.util.*;import java.util.Scanner;import java.io.File;public class program2{		public static void main(String[] args) throws java.io.FileNotFoundException	{		//create Scanner for input		Scanner sc = new Scanner(System.in);				FileOutputStream file1 = new FileOutputStream("questions.txt");						//use PrintWriter to handle output		PrintWriter pr = new PrintWriter(file1);				 				double distanceA;		int numberA;		int numberB;		int numberC;		float minutesA;		float minutesB;				Boolean done = false;						//find out if the user lives on campus		System.out.println("DO you live on campus?");		String campus = sc.next();		if( "no".equalsIgnoreCase(campus) )		{				//find out how far the user lives from campus		System.out.println("How far do you live from campus (miles)?");			distanceA = sc.nextDouble();		pr.println(distanceA);						}						if("yes".equalsIgnoreCase(campus) );					done = true;				//find out if user has bike			System.out.println("Do you have a bike?");		String bike = sc.next(); 		if ( "yes".equalsIgnoreCase(bike) )		{			//find out how many times on average the user uses bike		System.out.println("On average, how many times do you bike to campus?");			numberA = sc.nextInt();		pr.println(numberA);					//find out how many minutes it takes to bike to campus		System.out.println("How many minutes does it take to bike to campus?");			minutesA = sc.nextFloat();		pr.println(minutesA);				if("no".equalsIgnoreCase(bike) );					done = true;		} 				//find out if user lives on bus line		String bus = ("Do you live on a bus line?");		if ( "yes".equalsIgnoreCase(bus) )		{						//find out how often user uses bus line		String number = ("On average, how many times do you use the bus to campus?");			numberB = Integer.parseInt(number);		System.out.println(numberB);				numberB = sc.nextInt();			//find out how many minutes it takes to ride the bus to campus		String minutes = ("How many minutes does it take to ride the bus to campus?");			minutesB = Float.parseFloat(minutes);		System.out.println(minutesB);				minutesB = sc.nextFloat();			if("no".equalsIgnoreCase(bus) );					done = true;		}				//find out if user has car		String car = ("Do you have a car?");		if ( "yes".equalsIgnoreCase(car) )		{				//find out how often user uses car to drive to campus		String number = ("On average, how many times do you drive your car to campus?");			numberC = Integer.parseInt(number);		System.out.println(numberC);				numberC = sc.nextInt();				//find out where user parks		String inputStr = JOptionPane.showInputDialog(null, "Where do you usually park on campus?");				if("no".equalsIgnoreCase(car) );					done = true;						}		pr.close();		file1.close();		}}