Need help on this MPG program
Hi all,
The purpose of this program is listed in
// Inputs the miles driven and gallons used (both integers) for each tankful.
// Calculates and displays miles per gallon obtained for each tankful and print
// the combined miles per gallon obtained for all tankfuls up to this point.
// All results should be floating point. Use Scanner and sentinel-controlled
// repetition to obtain data from the user.
// Exercise 4.17 MPG.java
import java.util.Scanner;
public class MPG
private int milesDriven;
private int gallonsUsed;
private float result;
public void setMilesDriven( int miles )
milesDriven = miles;
public void setGallonsUsed( int gallons )
gallonsUsed = gallons;
public String getMilesDriven( int miles )
return milesDriven; // error occurs here
public String getGallonsUsed( int gallons )
return gallonsUsed;
public MPG( float result )
result = gallons * miles;
System.out.printf( result);
I try to compile this program, but the error I get is "incompatible types-found int but expected java.lang.String. How do I fix this, and how do I sentinel control? If you can help me with these two things, I'd appreciate it.
What has this got to do with algorithms?
Please post your question in a more appropriate part of the forum.
I suggest one of these:
New To Java Technology: http://forum.java.sun.com/forum.jspa?forumID=54
Java Programming: http://forum.java.sun.com/forum.jspa?forumID=31
Similar Messages
-
Plz need help with this hashmap program
as far as i know, this hashmap program works, but i cant get it to compile correctly because of one line error:
phoneArray[2] = int f;
the second position in phoneArray is and will always be a number, but the array is a String array, making it difficult for me to take the number in that position and change it.
In actuality, the number is a score (a grade) and i need to take it to change it to a letter grade, where it will later be spit out in order from Name, Year, Score, Grade.
plz help, this is a school assignment and its driving me mad.
import java.util.*;
import java.io.*;
* A class that represents a phone book. This phone
* book maps names to phone numbers. This will
* read teh phone book information from a file.
public class CourseData2 {
/////////////////// fields ///////////////////
private String fileName;
private Map phoneMap = new HashMap();
/////////////////// constructors ///////////////////
* Constructor that takes a file name and reads
* in the names and phone numbers from a file.
* @param file the name of the file to read
public CourseData2(String file) {
this.fileName = file;
// Read the map information in form the file
readInfoFromFile();
} // constructor
/////////////////// methods ///////////////////
* Get the phone number for hte passed nam
* @param name the name to look up in hte map
* @return the phone number if found, else null
public String getPhoneNumber(String name) {
String phoneNumber = (String) phoneMap.get(name);
return phoneNumber;
} // method getPhoneNumber()
* Method to read the phone information from a
* file and use it to fill hte map
public void readInfoFromFile() {
String line = null;
String[] phoneArray = null;
try {
// create the reader
BufferedReader reader =
new BufferedReader(new FileReader(fileName));
// loop reading from the file
while ((line = reader.readLine()) != null) {
if (line.indexOf(":") >= 0) {
phoneArray = line.split(":");
phoneMap.put(phoneArray[0].trim(),
phoneArray[1].trim(),
phoneArray[2].trim());
} // if
} // while
(int)phoneArray[2] = int f;
if (f < 60) { (String)a = "E";}
else if (60 <= f < 70) { (String)f = "D";}
else if (70 <= f < 80) { (String)f = "C";}
else if (70 <= f < 90) { (String)f = "B";}
else if (90 <= f) { (String)a = "A";}
// Close the reader
reader.close();
} // try
catch (FileNotFoundException ex) {
SimpleOutput.showError("Could not find the file \"" + fileName + "\".");
} // catch
catch (Exception ex) {
ex.printStackTrace();
} // catch
} // method readInfoFromFile()
public void printBook() {
// Sort hashtable.
Vector phoneVector = new Vector(phoneMap.keySet());
Collections.sort(phoneVector);
// Display (sorted) hashtable.
for (Enumeration phoneEnumeration = phoneVector.elements(); phoneEnumeration.hasMoreElements();) {
String key = (String)phoneEnumeration.nextElement();
System.out.println("Name: " + key + ", Year: " + phoneMap.get(key) + ", Score: " + phoneMap.get(key) + ", Grade: " + phoneMap.get(key));
} // for
} // method printBook()
/* main method for testing */
public static void main(String[] args) {
CourseData2 phoneBook = new CourseData2("scores12.txt");
System.out.println(phoneBook.getPhoneNumber("Lee"));
System.out.println(phoneBook.getPhoneNumber("Smith"));
phoneBook.printBook();
} // main()
} // classafter much time and editing, this is the revised coding:
import java.util.*;
import java.io.*;
* A class that represents a class score book. This
* book maps names to scores and grades. This will
* read the names, scores and grade information from a file.
public class CourseData2 {
/////////////////// fields ///////////////////
private String fileName;
private Map phoneMap = new HashMap();
/////////////////// constructors ///////////////////
* Constructor that takes a file name and reads
* in the names and phone numbers from a file.
* @param file the name of the file to read
public CourseData2(String file) {
this.fileName = file;
// Read the map information in form the file
readInfoFromFile();
} // constructor
/////////////////// methods ///////////////////
* Get the phone number for hte passed nam
* @param name the name to look up in hte map
* @return the phone number if found, else null
public String getPhoneNumber(String name) {
String phoneNumber = (String) phoneMap.get(name);
return phoneNumber;
} // method getPhoneNumber()
* Method to read the phone information from a
* file and use it to fill hte map
public void readInfoFromFile() {
String line = null;
String[] phoneArray = null;
String a = "";
try {
// create the reader
BufferedReader reader =
new BufferedReader(new FileReader(fileName));
// loop reading from the file
while ((line = reader.readLine()) != null) {
while ((line = reader.readLine()) != null) {
if (line.indexOf(":") >= 0) {
phoneArray = line.split(":");
int f = Integer.parseInt(phoneArray[2]);
if (0 <= f && f <= 100) {
if (0 <= f && f < 60) { a = "E";}
else if (60 <= f && f < 70) { a = "D";}
else if (70 <= f && f < 80) { a = "C";}
else if (80 <= f && f < 90) { a = "B";}
else if (90 <= f && f <= 100) { a = "A";}
} // if f between 0 and 100
else if ( f > 100 && f < 0 ) {
SimpleOutput.showError("Score is not an integer");
String g = new String();
g = phoneArray[2];
}//if < 0
}// if (line.index....
phoneMap.put(phoneArray[0].trim(),
(phoneArray[1].trim() + phoneArray[2].trim() + (String)a));
} // while2
} // while
// Close the reader
reader.close();
} // try
catch (FileNotFoundException ex) {
SimpleOutput.showError("Could not find the file \"" + fileName + "\".");
} // catch
catch (Exception ex) {
ex.printStackTrace();
} // catch
} // method readInfoFromFile()
public void printBook() {
// Sort hashtable.
Vector phoneVector = new Vector(phoneMap.keySet());
Collections.sort(phoneVector);
// Display (sorted) hashtable.
for (Enumeration phoneEnumeration = phoneVector.elements(); phoneEnumeration.hasMoreElements();) {
String key = (String)phoneEnumeration.nextElement();
System.out.println("Name: " + key + ", Year: " + phoneMap.get(key) + ", Score: " + phoneMap.get(key) + ", Grade: " + phoneMap.get(key));
} // for
} // method printBook()
/* main method for testing */
public static void main(String[] args) {
CourseData2 phoneBook = new CourseData2("scores12.txt");
System.out.println(phoneBook.getPhoneNumber("Depp"));
System.out.println(phoneBook.getPhoneNumber("Gonzales"));
System.out.println(phoneBook.getPhoneNumber("Jenkins"));
System.out.println(phoneBook.getPhoneNumber("Lee"));
System.out.println(phoneBook.getPhoneNumber("Mac Donald"));
System.out.println(phoneBook.getPhoneNumber("O'Malley"));
System.out.println(phoneBook.getPhoneNumber("Price"));
System.out.println(phoneBook.getPhoneNumber("Ramesh"));
System.out.println(phoneBook.getPhoneNumber("Smith"));
System.out.println(phoneBook.getPhoneNumber("Winston"));
phoneBook.printBook();
} // main()
} // classthis has no errors, but gives me 4 warnings, which i can't solve, plz help -
I need help w/ This: missing gina dll after installation...
I need help w/ This: missing gina dll after installation of linksys adaptor on Win XP.
Thank youI assume you are facing this error on wireless USB adapter ... WUSB54GC .... uninstall the adapter from all programs >> unplug & replug the adapter >> Install the drivers using found new hardware >>
Once installed use windows wireless configuration to connect to the wireless network .....
See if it works ..... -
I need help fixing this... i can't get PDF to open
[2011-08-07:20:00:49] Launching subprocess with commandline c:\Program Files (x86)\Common Files\Adobe AIR\Versions\1.0\Resources\Adobe AIR Updater -installupdatecheck
[2011-08-07:20:00:49] Runtime Installer end with exit code 0
[2011-08-07:20:00:49] Runtime Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-07:20:00:49] Commandline is: -installupdatecheck
[2011-08-07:20:00:49] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-07:20:00:49] Performing pingback request
[2011-08-07:20:00:50] Pingback request completed with HTTP status 200
[2011-08-07:20:00:50] Starting runtime background update check
[2011-08-07:20:00:50] Begin Background update download from http://airdownload.adobe.com/air/3/background/windows/x86/patch/2.7.0.19530/update
[2011-08-07:20:00:50] Unpackaging http://airdownload.adobe.com/air/3/background/windows/x86/patch/2.7.0.19530/update to C:\Users\Troy M\AppData\Roaming\Adobe\AIR\Updater\Background
[2011-08-07:20:00:50] Runtime update not available
[2011-08-07:20:00:50] Unpackaging cancelled
[2011-08-07:20:00:50] Runtime Installer end with exit code 0
[2011-08-07:20:01:23] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-07:20:01:23] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\SalesReceiptReport_08082011_010122AM.pdf"
[2011-08-07:20:01:23] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-07:20:01:24] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/SalesReceiptReport_080820 11_010122AM.pdf to C:\Users\Troy M\AppData\Local\Temp\fla54C3.tmp
[2011-08-07:20:01:24] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
[2011-08-07:20:01:29] Application Installer end with exit code 7
[2011-08-07:20:01:33] Runtime Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-07:20:01:33] Commandline is: -arp:uninstall
[2011-08-07:20:01:33] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-07:20:01:37] Relaunching with elevation
[2011-08-07:20:01:37] Launching subprocess with commandline c:\program files (x86)\common files\adobe air\versions\1.0\resources\adobe air updater.exe -eu
[2011-08-07:20:01:37] Runtime Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-07:20:01:37] Commandline is: -stdio \\.\pipe\AIR_2996_0 -eu
[2011-08-07:20:01:37] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-07:20:01:37] Starting runtime uninstall. Uninstalling runtime version 2.7.0.19530
[2011-08-07:20:01:37] Uninstalling product with GUID {FDB3B167-F4FA-461D-976F-286304A57B2A}
[2011-08-07:20:01:39] Runtime Installer end with exit code 0
[2011-08-07:20:01:39] Elevated install completed
[2011-08-07:20:01:39] Runtime Installer end with exit code 0
[2011-08-08:05:12:23] Runtime Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-08:05:12:23] Commandline is: -silent
[2011-08-08:05:12:23] No installed runtime detected
[2011-08-08:05:12:23] Starting silent runtime install. Installing runtime version 2.7.0.19530
[2011-08-08:05:12:24] Installing msi at c:\users\troym~1\appdata\local\temp\airb8a4.tmp\setup.msi with guid {FDB3B167-F4FA-461D-976F-286304A57B2A}
[2011-08-08:05:12:43] Runtime Installer end with exit code 0
[2011-08-08:05:14:53] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-08:05:14:53] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\SalesReceiptReport_08082011_101451AM.pdf"
[2011-08-08:05:14:53] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-08:05:14:54] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/SalesReceiptReport_080820 11_101451AM.pdf to C:\Users\Troy M\AppData\Local\Temp\fla1120.tmp
[2011-08-08:05:14:54] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
[2011-08-08:05:15:01] Application Installer end with exit code 7
[2011-08-08:05:16:11] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-08:05:16:11] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\ShowSummaryReport_08082011_101610AM.pdf"
[2011-08-08:05:16:11] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-08:05:16:11] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/ShowSummaryReport_0808201 1_101610AM.pdf to C:\Users\Troy M\AppData\Local\Temp\fla3F41.tmp
[2011-08-08:05:16:11] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
[2011-08-08:05:16:16] Application Installer end with exit code 7
[2011-08-08:06:29:43] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-08:06:29:43] Commandline is: "C:\Users\Troy M\Documents\hs_11jul.pdf"
[2011-08-08:06:29:43] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-08:06:29:44] Unpackaging file:///C:/Users/Troy%20M/Documents/hs_11jul.pdf to C:\Users\Troy M\AppData\Local\Temp\fla13FC.tmp
[2011-08-08:06:29:45] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
[2011-08-08:06:29:46] Application Installer end with exit code 7
[2011-08-08:06:30:25] Runtime Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-08:06:30:25] Commandline is:
[2011-08-08:06:30:25] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-08:06:30:28] Launching subprocess with commandline c:\Program Files (x86)\Common Files\Adobe AIR\Versions\1.0\Resources\Adobe AIR Updater -installupdatecheck
[2011-08-08:06:30:28] Runtime Installer end with exit code 0
[2011-08-08:06:30:29] Runtime Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-08:06:30:29] Commandline is: -installupdatecheck
[2011-08-08:06:30:29] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-08:06:30:29] Performing pingback request
[2011-08-08:06:30:29] Pingback request completed with HTTP status 200
[2011-08-08:06:30:29] Starting runtime background update check
[2011-08-08:06:30:29] Begin Background update download from http://airdownload.adobe.com/air/3/background/windows/x86/patch/2.7.0.19530/update
[2011-08-08:06:30:29] Unpackaging http://airdownload.adobe.com/air/3/background/windows/x86/patch/2.7.0.19530/update to C:\Users\Troy M\AppData\Roaming\Adobe\AIR\Updater\Background
[2011-08-08:06:30:30] Runtime update not available
[2011-08-08:06:30:30] Unpackaging cancelled
[2011-08-08:06:30:30] Runtime Installer end with exit code 0
[2011-08-08:06:31:02] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-08:06:31:02] Commandline is: "C:\Users\Troy M\Documents\hs_11jul.pdf"
[2011-08-08:06:31:02] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-08:06:31:02] Unpackaging file:///C:/Users/Troy%20M/Documents/hs_11jul.pdf to C:\Users\Troy M\AppData\Local\Temp\fla43F2.tmp
[2011-08-08:06:31:02] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
[2011-08-08:06:31:05] Application Installer end with exit code 7
[2011-08-08:06:31:08] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-08:06:31:08] Commandline is: "C:\Users\Troy M\Documents\hs_11jul.pdf"
[2011-08-08:06:31:08] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-08:06:31:08] Unpackaging file:///C:/Users/Troy%20M/Documents/hs_11jul.pdf to C:\Users\Troy M\AppData\Local\Temp\fla5C13.tmp
[2011-08-08:06:31:08] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
[2011-08-08:06:31:10] Application Installer end with exit code 7
[2011-08-08:06:31:25] Runtime Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-08:06:31:25] Commandline is: -arp:uninstall
[2011-08-08:06:31:25] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-08:06:31:27] Runtime Installer end with exit code 6
[2011-08-08:06:32:54] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-08:06:32:54] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\ShowSummaryReport_08082011_113253AM.pdf"
[2011-08-08:06:32:54] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-08:06:32:55] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/ShowSummaryReport_0808201 1_113253AM.pdf to C:\Users\Troy M\AppData\Local\Temp\flaFB7D.tmp
[2011-08-08:06:32:55] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
[2011-08-08:06:34:32] Application Installer end with exit code 7
[2011-08-08:06:36:06] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-08:06:36:06] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\ShowSummaryReport_08082011_113606AM.pdf"
[2011-08-08:06:36:06] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-08:06:36:06] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/ShowSummaryReport_0808201 1_113606AM.pdf to C:\Users\Troy M\AppData\Local\Temp\flaE83C.tmp
[2011-08-08:06:36:06] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
[2011-08-08:06:36:08] Application Installer end with exit code 7
[2011-08-08:06:40:11] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-08:06:40:11] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\ShowSummaryReport_08082011_114010AM.pdf"
[2011-08-08:06:40:11] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-08:06:40:11] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/ShowSummaryReport_0808201 1_114010AM.pdf to C:\Users\Troy M\AppData\Local\Temp\flaA488.tmp
[2011-08-08:06:40:11] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
[2011-08-08:06:40:17] Application Installer end with exit code 7
[2011-08-08:06:41:40] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-08:06:41:40] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\SalesReceiptReport_08082011_114140AM.pdf"
[2011-08-08:06:41:40] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-08:06:41:40] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/SalesReceiptReport_080820 11_114140AM.pdf to C:\Users\Troy M\AppData\Local\Temp\fla138.tmp
[2011-08-08:06:41:41] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
[2011-08-08:06:42:57] Application Installer begin with version 2.7.0.19530 on Windows 7 x86
[2011-08-08:06:42:57] Commandline is: "C:\Users\Troy M\PamperedPartnerPlus\workspace\.report\SalesReceiptReport_08082011_114257AM.pdf"
[2011-08-08:06:42:57] Installed runtime (2.7.0.19530) located at c:\Program Files (x86)\Common Files\Adobe AIR
[2011-08-08:06:42:57] Unpackaging file:///C:/Users/Troy%20M/PamperedPartnerPlus/workspace/.report/SalesReceiptReport_080820 11_114257AM.pdf to C:\Users\Troy M\AppData\Local\Temp\fla2E11.tmp
[2011-08-08:06:42:58] Got an unexpected fatal error while unpackaging: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="not an AIR file" errorID=0]
[2011-08-08:06:43:02] Application Installer end with exit code 7
[2011-08-08:06:44:48] Application Installer end with exit code 7i have reader... and this is the error message i get when i attempt to open one
sorry, an error has occured.
The application could not be installed because the installer file is damaged. Try obtaining a new installer file from the application author.
Date: Mon, 8 Aug 2011 11:19:37 -0600
From: [email protected]
To: [email protected]
Subject: I need help fixing this... i can't get PDF to open
To open files with the .pdf extension, please use http://get.adobe.com/reader/.
Thanks,
Chris
> -
Can somebody please help me read this file?
The data being read come from a file. the data looks like this
Date Time X Y Depth Temp
14-Feb-05 10:08:48 3002 -2571 26 3348
14-Feb-05 10:08:48 3039 -2573 34 3345
14-Feb-05 10:08:48 3181 -2573 42 3345
14-Feb-05 10:08:49 2841 -2573 49 3342
14-Feb-05 10:08:49 2455 -2573 58 3345
the data is then read into the program in the loadData() function shown
The problem is it only reads the header. It never reads the data.public void loadData ()
// Display the open file dialog, wait for a response.
JFileChooser chooser = new JFileChooser();
int choice = chooser.showOpenDialog(frame);
// If no file was selected, bail out.
if (choice != JFileChooser.APPROVE_OPTION)
return;
// Get the file, attempt to open the file and
// read the data points.
File dataFile = chooser.getSelectedFile ();
try
Scanner input = new Scanner (dataFile);
// Loop, reading pairs of input.
String headers = input.nextLine(); //read the headers
//System.out.println( in); //skip the headers to the data
while (input.hasNextInt())
int date = input.nextInt(); //read date
int time = input.nextInt(); //read time
int x = input.nextInt(); //read x
int y = input.nextInt(); //read y
int depth = input.nextInt(); //read depth
if (!input.hasNextInt())
break;
int temp = input.nextInt(); //read temperature
graph.setDataPoint (new Point (x, y));
graph.setDomainLabel ("x");
graph.setRangeLabel ("Depth");*/
catch (FileNotFoundException e)
System.err.println ("Unable to read data points from " + dataFile.getName
I really need help on this crewCan somebody please help me read this file?
The data being read come from a file. the data looks
like this
Date Time X
Y Depth Temp
14-Feb-05 10:08:48 3002 -2571 26 3348
14-Feb-05 10:08:48 3039 -2573 34 3345
14-Feb-05 10:08:48 3181 -2573 42 3345
14-Feb-05 10:08:49 2841 -2573 49 3342
14-Feb-05 10:08:49 2455 -2573 58 3345
the data is then read into the program in the
loadData() function shown
The problem is it only reads the header. It never
reads the data.public void loadData ()
// Display the open file dialog, wait for a
r a response.
JFileChooser chooser = new JFileChooser();
int choice = chooser.showOpenDialog(frame);
// If no file was selected, bail out.
if (choice != JFileChooser.APPROVE_OPTION)
return;
// Get the file, attempt to open the file and
// read the data points.
File dataFile = chooser.getSelectedFile ();
try
Scanner input = new Scanner (dataFile);
// Loop, reading pairs of input.
String headers = input.nextLine(); //read the
e headers
//System.out.println( in); //skip the headers to
o the data
while (input.hasNextInt())
int date = input.nextInt(); //read date
int time = input.nextInt(); //read time
int x = input.nextInt(); //read x
int y = input.nextInt(); //read y
int depth = input.nextInt(); //read depth
if (!input.hasNextInt())
break;
int temp = input.nextInt(); //read
nt(); //read temperature
graph.setDataPoint (new Point (x, y));
graph.setDomainLabel ("x");
graph.setRangeLabel ("Depth");*/
catch (FileNotFoundException e)
System.err.println ("Unable to read data
ead data points from " + dataFile.getName
I really need help on this
crew
I modified the code but getting an error when I call the function
How do I catch an exception in this -
pls i need help for this simple problem of my palm os zire 72. pls share your ideas with me.... i tried to connect my palm os zire72 in my desktop computer using my usb cable but i can't see it in my computer.. my palm has no problem and it works well. the only problem is that, my desktop computer can't find my palm when i tried to connect it using usb cable. is thier any certain driver or installer needed for it so that i can view my files in my palm using the computer. where i can download its driver? is there somebody can help me for this problem? just email me pls at [email protected] i really accept any suggestions for this problem. thanks for your help...
If you are using Windows Vista go to All Programs/Palm and click on the folder and select Hot Sync Manager and then try to sync with the USB cable. If you are using the Windows XP go to Start/Programs/Palm/Hot Sync Manager and then try to sync. If you don’t have the palm folder at all on your PC you have to install it. Here is the link http://kb.palm.com/wps/portal/kb/common/article/33219_en.html that version 4.2.1 will be working for your device Zire 72.
-
My Mac was updated to Ÿosemite OS and since then the PS5 software doesn't open. I need help on this subject please.
They error message I get is "An unexpected and unrecoverable problem has occurred. Photoshop will now exit."
This only started after I upgraded my OS to Yosemite.The upgrade has been know to break Photoshop CS5 installs. An Uninstall/Reinstall may be necessary.
-
I need help with this script please ASAP
So I need this to work properly, but when ran and the correct answer is chosen the app quits but when the wrong answer is chosen the app goes on to the next question. I need help with this ASAP, it is due tommorow. Thank you so much for the help if you can.
The script (Sorry if it's a bit long):
#------------Startup-------------
display dialog "Social Studies Exchange Trviva Game by Justin Parzik" buttons {"Take the Quiz", "Cyaaaa"} default button 1
set Lolz to (button returned of the result)
if Lolz is "Cyaaaa" then
killapp()
else if Lolz is "Take the Quiz" then
do shell script "say -v samantha Ok starting in 3…2…1…GO!"
#------------Question 1-----------
display dialog "Around age 11, many boys left their fathers to become…" buttons {"Scholars", "Warriors", "Apprentices"}
set A1 to (button returned of the result)
if A1 is "Apprentices" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#----------Question 2--------
display dialog "Most children were taught
to read so that they could understand the…" buttons {"Music of Mozart", "Bible", "art of cooking"}
set A2 to (button returned of the result)
if A2 is "Bible" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#------------Question 3---------
display dialog "In the 1730s and 1740s, a religious movement called the_______swept through the colonies." buttons {"Glorius Revolution", "Great Awakening", "The Enlightenment"}
set A3 to (button returned of the result)
if A3 is "Great Awakening" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#-----------Question 4--------
display dialog "_______ was
a famous American Enlightenment figure." buttons {"Ben Franklin", "George Washington", "Jesus"}
set A4 to (button returned of the result)
if A4 is "Ben Franklin" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#----------Question 5-------
display dialog "______ ownership gave colonists political rights as well as prosperity." buttons {"Land", "Dog", "Slave"}
set A5 to (button returned of the result)
if A5 is "Land" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 6--------
display dialog "The first step toward guaranteeing these rights came in 1215. That
year, a group of English noblemen forced King John to accept the…" buttons {"Declaration of Independence", "Magna Carta", "Constitution"}
set A6 to (button returned of the result)
if A6 is "Magna Carta" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#----------Question 7--------
display dialog "England's cheif lawmaking body was" buttons {"the Senate", "Parliament", "King George"}
set A7 to (button returned of the result)
if A7 is "Parliament" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#--------Question 8-----
display dialog "Pariliament decided to overthrow _______ for not respecting their rights" buttons {"King James II", "King George", "King Elizabeth"}
set A8 to (button returned of the result)
if A8 is "King James II" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#--------Question 9------
display dialog "Parliament named ___ and ___ as England's new monarchs in something called ____." buttons {"William/Mary/Glorius Revolution", "Adam/Eve/Great Awakening", "Johhny/Mr.Laphalm/Burning of the hand ceremony"}
set A9 to (button returned of the result)
if A9 is "William/Mary/Glorius Revolution" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 10-----
display dialog "After accepting the throne William and Mary agreed in 1689 to uphold the English Bill of _____." buttons {"Money", "Colonies", "Rights"}
set A10 to (button returned of the result)
if A10 is "Rights" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 11------
display dialog "By the late 1600s French explorers had claimed the ___ River Valey" buttons {"Mississippi", "Ohio", "Hudson"}
set A11 to (button returned of the result)
if A11 is "Ohio" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#------Question 12---------
display dialog "______ was sent to ask the French to leave 'English Land'." buttons {"Johhny Tremain", "George Washington", "Paul Revere"}
set A12 to (button returned of the result)
if A12 is "George Washington" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 13-------
display dialog "_____ proposed the Albany Plan of Union" buttons {"George Washingon", "Ben Franklin", "John Hancock"}
set A13 to (button returned of the result)
if A13 is "Ben Franklin" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#--------Question 14------
display dialog "The __________ declared that England owned all of North America east of the Mississippi" buttons {"Proclomation of England", "Treaty of Paris", "Pontiac Treaty"}
set A14 to (button returned of the result)
if A14 is "" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#-------Question 15-------
display dialog "Braddock was sent to New England so he could ______" buttons {"Command an attack against French", "Scalp the French", "Kill the colonists"}
set A15 to (button returned of the result)
if A15 is "Command an attack against French" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#------TheLolQuestion-----
display dialog "____ is the name of the teacher who runs this class." buttons {"Mr.White", "Mr.John", "Paul Revere"} default button 1
set LOOL to (button returned of the result)
if LOOL is "Mr.White" then
do shell script "say -v samantha Congratulations…you…have…common…sense"
else
do shell script "say -v alex Do…you…have…eyes?"
#------END------
display dialog "I hope you enjoyed the quiz!" buttons {"I did!", "It was horrible"}
set endmenu to (button returned of the result)
if endmenu is "I did!" then
do shell script "say -v samantha Your awesome"
else
do shell script "say -v alex Go outside and run a lap"
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end ifUse code such as:
display dialog "Around age 11, many boys left their fathers to become…" buttons {"Scholars", "Warriors", "Apprentices"}
set A1 to (button returned of the result)
if A1 is "Apprentices" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
return
end if
#----------Question 2--------
display dialog "Most children were taught to read so that they could understand the…" buttons {"Music of Mozart", "Bible", "art of cooking"}
set A2 to (button returned of the result)
if A2 is "Bible" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
return
end if
(90444) -
I purchased Adobe Acrobat x Pro recently and installed it, I have compatibility issues vision 2013. The adobe pdf converter plug in stays inactive despite all my efforts to activate it, I need help with this? How can i get the plug in to work with Visio 2013?
For MS Visio (any version) only the appropriate version of Acrobat *PRO* provides PDFMaker for Visio.
For Visio 2013 specifically you must have Acrobat XI Pro (updated to at least 11.0.1).
See:
http://helpx.adobe.com/acrobat/kb/compatible-web-browsers-pdfmaker-applications.html
Be well... -
I purchased Adobe Acrobat x Pro recently and installed it, I have compatibility issues vision 2013. The adobe pdf converter plug in stays inactive despite all my efforts to activate it, I need help with this? How can i get the plug in to work with Visio 2013?
For MS Visio (any version) only the appropriate version of Acrobat *PRO* provides PDFMaker for Visio.
For Visio 2013 specifically you must have Acrobat XI Pro (updated to at least 11.0.1).
See:
http://helpx.adobe.com/acrobat/kb/compatible-web-browsers-pdfmaker-applications.html
Be well... -
Need help with this xml gallery !!!
i have build a gallery but its very simple...... it takes images from xml file.
i have attached all files in zip.
i just want two things if anyone can help.
first when i press next button it goes to next image but with no effect. it just displays next image ... i want to incorporate a sliding effect when the image is changed to another.
and second i want to use autoplay feature.
as soon as swf starts the images came one by one with difference of few seconds.
thx in advance... i really need help in this....!You're welcome.
I don't have an example to offer for the autorun. You should be able to think it thru. One key, as I mentioned is to preload all of the images first, that will allow for smooth playing of the show--no waiting for images to load between changes. You can load them into empty movieclips and hide them (_viisible = false) until they are needed. You could load them when called for, but you would have to put conditions on the displaying of things until the image loads, which will change when they are all loaded, so I recommend just loading them all first.
For the timing you can use setInterval. If something is going to be allowed to interupt the autorun, then you will need to make use of the clearInterval function as well, so that you stop the clock.
Since you will be wanting to know when things are loaded, you will need to use the MovieClipLoader.loadClip method for loading the images instead of using loadMovie. This is because the MovieClipLoader class supports having an event listener. If you look in the help documents in the MovieClipLoader.addListener section, there is an example there that provides a fairly good complete overview of using the code. The only difference is you'd be looking for the onLoadComplete event rather than the onLoadInit event. -
Need help for writing extract program
hi
i need help for writing extract program to retriew data from legacy system.
i already developed bdc programs for me31k and me21.
my requirement is to write extract program s for those t.codes.
to retriew data from legacy system and stored in flat file.i need help with a java program. it is a program that allows the user to enter a student's GPA, number of extracurricular activities, and number of service activities. The user can not enter a gpa above 4.0 or below 0. The user can not enter a negative number for the number of both activities. If the student meets the following criteria: 1) GPA of 3.8 or above and at least one extracurricular activity and one service activity, 2) GPA below 3.8 but at least 3.4 and a total of at least three extracurricular and service activities, 3) GPA below 3.4 but at least 3.0 and at least two extracurricular activities and three service activities, the message "Scholarship candidate" should display. If the student does not meet the criteria above, then the message"not a candidate" should display. Can you help me, please?
You haven't posted ANY 'java program' for us to help with.
The forum is NOT a coding service. It is to help you with YOUR code.
Post the code you have written and SHOW us (don't just tell us) how you compile it and execute it and the results you get. Then we can help you with any problems you are are having.
If you need help understanding just what the program should be doing you need to ask your instructor to clarify the assignment. -
I need help on This SQL problem ASAP :)
Hi All,
I need help on this....
I have a table...
Say table name: one
with these values
premnum status
1234 C
1234 F
1234 P
1234 F
5678 C
5678 F
5678 P
9112 C
9112 F
9112 P
9112 F
3456 C
3456 F
3456 P
7890 C
7890 P
7890 F
Now, I want to output only those premnum with status = 'C' and those premnum with Status 'F' having a count > 1 (with two status = 'F')
So the output would be something like this
premnum status
1234 C
1234 F
1234 F
5678 C
9112 C
9112 F
9112 F
3456 C
7890 C
I really need help on this asap...
I need the SQL statement on this....
Thank you in advance. :)
Edited by: 804697 on Oct 23, 2010 9:45 PMHi,
you can use the following query.
CREATE TABLE PREM_TEST ( premnum NUMBER , STATUS VARCHAR2(1));
INSERT INTO PREM_TEST VALUES(1234 ,'C');
INSERT INTO PREM_TEST VALUES(1234 ,'F');
INSERT INTO PREM_TEST VALUES(1234 ,'P');
INSERT INTO PREM_TEST VALUES(1234 ,'F');
INSERT INTO PREM_TEST VALUES(5678 ,'C');
INSERT INTO PREM_TEST VALUES(5678 ,'F');
INSERT INTO PREM_TEST VALUES(5678 ,'P');
INSERT INTO PREM_TEST VALUES(9112 ,'C');
INSERT INTO PREM_TEST VALUES(9112 ,'F');
INSERT INTO PREM_TEST VALUES(9112 ,'P');
INSERT INTO PREM_TEST VALUES(9112 ,'F');
INSERT INTO PREM_TEST VALUES(3456 ,'C');
INSERT INTO PREM_TEST VALUES(3456 ,'F');
INSERT INTO PREM_TEST VALUES(3456 ,'P');
INSERT INTO PREM_TEST VALUES(7890 ,'C');
INSERT INTO PREM_TEST VALUES(7890 ,'P');
INSERT INTO PREM_TEST VALUES(7890 ,'F');
SELECT PREMNUM , STATUS
FROM PREM_TEST
WHERE STATUS = 'C'
OR (PREMNUM , STATUS ) IN ( SELECT PREMNUM , STATUS
FROM PREM_TEST
WHERE STATUS = 'F'
GROUP BY PREMNUM , STATUS
HAVING COUNT(*) > 1
PREMNUM S
1234 C
1234 F
1234 F
5678 C
9112 C
9112 F
9112 F
3456 C
7890 C
9 rows selected. -
Help urgently needed, I have installed Logic Pro 9, since then my Final Cut Pro X keep freezing. Anyone what is wrong and how to solve it? I desperately need help on this. Apple support says I have to pay £85 for to help me. Thanks
Just a word of advice. Never ever use the word "urgent" on this forum
-
Hi!!
I urgently need help with this:
When I compile this in Flex Builder 3 it says: The element type 'mx:Application' must be terminated by the matching end-tag '</mx:Application>'.
but I have this end tag in my file, but when I try to switch from source view to desgin view it says, that: >/mx:Script> expected to terminate element at line 71, this is right at the end of the .mxml file. I have actionscript(.as) file for scripting data.
This is the mxml code to terminate apllication tag which I did as you can see:
MXML code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#007200, #000200]" width="1024" height="768" applicationComplete="popolni_vse()">
<mx:HTTPService id="bazaMME" url="lokalnabaza/baza_MME_svn.xml" showBusyCursor="true" resultFormat="e4x"/>
<mx:Script source="dajzaj.as"/>
<mx:states>
<mx:State name="Galerije">
<mx:SetProperty target="{panel1}" name="title" value="Galerije MME"/>
<mx:SetProperty target="{panel2}" name="title" value="opis slik"/>
<mx:SetProperty target="{panel3}" name="title" value="Opis Galerije"/>
<mx:AddChild relativeTo="{panel1}" position="lastChild">
<mx:HorizontalList x="0" y="22" width="713.09863" height="157.39436" id="ListaslikGalerije"></mx:HorizontalList>
</mx:AddChild>
<mx:SetProperty target="{text1}" name="text" value="MME opisi galerij "/>
<mx:AddChild relativeTo="{panel1}" position="lastChild">
<mx:Label x="217" y="346" text="labela za test" id="izbr"/>
</mx:AddChild>
<mx:SetProperty target="{label1}" name="text" value="26. November 2009@08:06"/>
<mx:SetProperty target="{label1}" name="x" value="845"/>
<mx:SetProperty target="{label1}" name="width" value="169"/>
<mx:SetProperty target="{Gale}" name="text" value="plac za Galerije"/>
</mx:State>
<mx:State name="Projekti"/>
</mx:states>
<mx:MenuBar id="MMEMenu" labelField="@label" showRoot="true" fillAlphas="[1.0, 1.0]" fillColors="[#043D01, #000000]" color="#9EE499" x="8" y="24"
itemClick="dajVsebino(event)" width="1006.1268" height="21.90141">
<mx:XMLList id="MMEmenuModel">
<menuitem label="O nas">
<menuitem label="reference podjetja" name="refMME" type="check" groupName="one"/>
<menuitem label="reference direktor" name="refdir" type="check" groupName="one"/>
<menuitem label="Kontakt" name="podatMME" groupName="one" />
<menuitem label="Kje smo" name="lokaMME" type="check" groupName="one" />
</menuitem>
<menuitem type="separator"/>
<menuitem label="Galerija">
<menuitem label="Slovenija" name="galSvn" type="check" groupName="one"/>
<menuitem label="Nemčija" name="galDeu" type="check" groupName="one" />
</menuitem>
<menuitem type="separator"/>
<menuitem label="projekti">
<menuitem label="Slovenija" name="projSvn" type="check" groupName="one"/>
<menuitem label="Nemčija" name="projDeu" type="check" groupName="one" />
<menuitem label="Madžarska" name="projHun" type="check" groupName="one"/>
</menuitem>
</mx:XMLList>
</mx:MenuBar>
<mx:Label x="845" y="10" text="25. November 2009@08:21" color="#FFFFFF" width="169" height="18.02817" id="label1"/>
<mx:Label x="746" y="10" text="zadnja posodobitev:" color="#FFFFFF"/>
<mx:Panel x="9" y="57" width="743.02814" height="688.4507" layout="absolute" title="Plac za Vsebino" id="panel1">
<mx:Text x="0" y="-0.1" text="MME vsebina" width="722.95776" height="648.4507" id="Gale"/>
</mx:Panel>
<mx:Label x="197.25" y="748.45" color="#FFFFFF" text="Copyright © 2009 MME d.o.o." fontSize="12" width="228.73239" height="20"/>
<mx:Label x="463.35" y="748.45" text="izdelava spletnih strani: FACTUM d.o.o." color="#FBFDFD" fontSize="12" width="287.60565" height="20"/>
<mx:Panel x="759" y="53" width="250" height="705.07043" layout="absolute" title="Plac za hitre novice" id="panel3">
<mx:Text x="0" y="0" text="MME novice" width="230" height="665.07043" id="text1"/>
<mx:Panel x="-10" y="325.35" width="250" height="336.61972" layout="absolute" title="začasna panela" color="#000203" themeColor="#4BA247" cornerRadius="10" backgroundColor="#4B9539" id="panel2">
<mx:Label x="145" y="53" text="vrednost" id="spremmen"/>
<mx:Label x="125" y="78" text="Label"/>
<mx:Label x="125" y="103" text="Label"/>
<mx:Label x="0" y="53" text="spremenljivka iz Menuja:"/>
<mx:Label x="45" y="78" text="Label"/>
<mx:Label x="45" y="103" text="Label"/>
</mx:Panel>
</mx:Panel>
<mx:Label x="9.9" y="10" text="plac za naslov MME vsebine" id="MMEnaslov" color="#040000"/>
</mx:states></mx:Application>I know it's been a while but… did you fix this?
It looks to me like you are terminating the <mx:Application> tag at the top. The opening tag should end like this: resultFormat="e4x">, not resultFormat="e4x"/> (Remove the /).
Carlos
Maybe you are looking for
-
EDI Integration---Using Seeburger Adapter
Hi All, I have a below requirement. EDI----->XI-- >SAP and vice versa. I am new to EDI integration,i would like to know the procedure steps to do the above scenario. Thanks in advance, AVR
-
Good afternoon, my name is Bruno, I got a Lumia 520, after the last update Lumia Black, I can not insert my photos or any wallpaper on the main screen to download apps thought could enter them on my smartphone, but accused the application need to upg
-
I have an old Flash file that must remain published to Flash player 7. I'm experience a complete failure of communication to JavaScript in IE7 when using getURL(), and am unsure how to resolve this issue. A call to a JavaScript function on the page f
-
BBC News Video not displaying/loading
This is an old topic, but I can find no entry since 2006 have I missed something? I can view YouTube, ITN any number of Quicktime sites, and I can listen to BBC sound only sites but not stream video content. Running Safari (through Rosetta) doesn't s
-
How to turn off mobile service and leave wifi on - iPhone 5
how do I turn off the cellular mobile phone service but leave wifi on when I am travelling (I have a second phone for travel use). Is it really as easy as hitting OFF on cellular in iOS6?