Results 1 to 4 of 4
- 04-19-2011, 04:58 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 2
- Rep Power
- 0
Unreported Exception? Please help!
What does this mean? I am new to Java (changing careers) and trying to go back to school after years out!
I am compiling and getting the following error:
DriverProj3.java:196: unreported exception java.io.IOException; must be caught or declared to be thrown
processDetail();
^
the script follows:
import java.io.*;
public class DriverProj3
{
public static void main(String args[]) throws IOException
{
Proj3 app;
app = new Proj3();
app.appMain();
} //end of main()
}
class Proj3
{
/* Instance Data Declarations */
String itemDesc; // Item description
int quantitySold; // Quantity of appliance sold
float unitPrice; // Sales Price per unit
float unitCost; // Cost per appliance
float salesTax; // enter sales tax as a decimal
float transactionAmt; // Quantity * Price
float transactionCost; // Quantity * Cost
float ttltransAmt; // Total amount of transactions
float ttltransCost; // Total transactions costs
float ttlProfit; // Total sales - total cost
float ttltaxColl; // Total tax collected
int ttlqtySld; // Total Qty Sold
float avgqtySold; // Total amount/ttl Qty
float minsalesAmt; // smallest sales amount
String minsalesDesc; // smalles sales description
int salesCnt; //
String numString; // number string input
BufferedReader stdin; // define stdin
/*appMain module calls for intialization, processing, output*/
public void appMain() throws IOException
{
BufferedReader stdin = new BufferedReader
(new InputStreamReader (System.in));
//create input string object
System.out.println("\n in fulfillment of the requirments for Project 3" );
initMonth();
processDetail();
updateTots();
updateMin();
} //end of appMain()
/*initialize month once */
void initMonth() throws IOException
{
salesTax = 0;
BufferedReader stdin = new BufferedReader
(new InputStreamReader (System.in));
//create input string object
System.out.print(" Input sales tax amount as decimal");
numString = stdin.readLine();
salesTax = Float.parseFloat(numString);
quantitySold = 0;
unitPrice = 0; // Sales Price per unit
unitCost = 0; // Cost per appliance
transactionAmt = 0; // Quantity * Price
transactionCost = 0; // Quantity * Cost
ttltransAmt =0; // Total amount of transactions
ttltransCost =0; // Total transactions costs
ttlProfit = 0; // Total sales - total cost
ttltaxColl = 0; // Total tax collected
ttlqtySld = 0; // Total Qty Sold
avgqtySold = 0; // Total amount/ttl Qty
minsalesAmt= 999999; // smallest sales amount
minsalesdesc = "a"; // smalles sales description
return;
}
// end of initMonth()
/* process monthly sales data */
void processDetail() throws IOException
{
BufferedReader stdin = new BufferedReader
(new InputStreamReader (System.in));
//create input string object
itemDesc = "a";
System.out.print(" Enter item description");
itemDesc = stdin.readLine();
{
if(itemDesc.equals("Done"))
outReport();
else
processdetailFin();
}
return;
}
/* process attendance for a single class */
void processdetailFin() throws IOException
{
BufferedReader stdin = new BufferedReader
(new InputStreamReader (System.in));
//create input string object
System.out.print(" Enter Quantity Sold ");
numString = stdin.readLine();
quantitySold = Integer.parseInt(numString);
System.out.print(" Enter Unit Price ");
numString = stdin.readLine();
unitPrice = Float.parseFloat(numString);
System.out.print(" Enter Unit Cost ");
numString = stdin.readLine();
unitCost = Float.parseFloat(numString);
updateTots();
}
//end processdetailFin()
/* update Min Sales and Description */
void updateMin()
{ {
if(transactionAmt < minsalesAmt)
updateminTwo();
else
minsalesAmt = minsalesAmt;
}
return;
} // end updateMin()
/*update totals */
void updateTots()
{
ttltransAmt = transactionAmt + ttltransAmt;
ttltransCost = transactionCost + ttltransCost;
ttlProfit = ttltransAmt - ttltransCost;
ttlqtySld = quantitySold + ttlqtySld;
salesCnt = salesCnt + 1;
avgqtySold = ttlqtySld/salesCnt;
return;
} //end updateTots()
/*update MINfinal */
updateminTwo()
{ {
minsalesAmt = transactionAmt;
itemDesc = minsalesDesc;
}
processDetail();
}
//end updateMinTwo
/*output sales numbers */
void outReport() throws IOException
{
System.out.println("\nTotal transactions amount is" + ttltransAmt);
//System.out.println("\nTotal transactions costs are" + ttltransCost);
//System.out.println("\nTotal Profit is" +ttlProfit);
//System.out.println("\nTotal taxes collected are" + ttlsalesTax);
//System.out.print("\nThe Average quantity sold is" + avgqtySold);
//System.out.print("\nThe Average quantity sold is" + minsalesAmt + "for item" + minsalesDesc);
initMonth();
}
}
// end outReport ()
-
You need to catch or throw the exception and you'll want to read the tutorial on exceptions to learn how to do this: Lesson: Exceptions (The Java™ Tutorials > Essential Classes)
- 04-19-2011, 05:44 PM #3
Also, for future reference. People are more likely to read your code if you put them in [code][/code] tags.
- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 04-19-2011, 07:26 PM #4
Member
- Join Date
- Apr 2011
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
unreported exception java.io.IOException
By fluffaykitties in forum New To JavaReplies: 11Last Post: 03-07-2011, 01:59 AM -
unreported exception java.lang.Exception; must be caught or declared to be thrown
By arc_remiel in forum New To JavaReplies: 5Last Post: 02-14-2011, 11:39 PM -
unreported exception -- reiro
By Reiro in forum New To JavaReplies: 4Last Post: 08-23-2010, 03:45 PM -
unreported exception (socket connection)
By Symbiot in forum New To JavaReplies: 7Last Post: 05-28-2010, 11:13 AM -
Unreported exception java.sql.SQLException
By javamula in forum AWT / SwingReplies: 4Last Post: 09-29-2009, 02:32 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks