directory structure change, organize by class number as opposed to mod number
Signed-off-by: Amrit Panesar <apanesar@4195tech.com>
This commit is contained in:
1 parent
2a3d6fc042
commit
8683384387
480 files changed
+7
No files matched your search
@@ -0,0 +1,37 @@
|
||||
/******************************************************************************
|
||||
* Project: Project 3b *
|
||||
* Class Name: DecFormat *
|
||||
* Author: Amrit Panesar -ASP ,o/ *
|
||||
* Last Edited: 08/20/2012 *
|
||||
* Hours: 0.25 Hours *
|
||||
* Purpose: To demonstrate the ability to create a conventionally named *
|
||||
* java application, the parsing of numeric strings with *
|
||||
* exception handling, format numeric output using Decimal *
|
||||
* Format, write to and read from a simple text file, use Decimal*
|
||||
* Format to format output *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class DecFormat
|
||||
{
|
||||
public static void main(String[] args) // main
|
||||
{
|
||||
DecimalFormat df3Pos = new DecimalFormat("#####,00.000"); //2a
|
||||
DecimalFormat df5Pos = new DecimalFormat("#######,00.0000"); //2b
|
||||
|
||||
double dLarge01 = 0.1535012260547;
|
||||
|
||||
System.out.println("dLarge01 formatted to 3 places: "
|
||||
+ df3Pos.format(dLarge01)); //2c
|
||||
|
||||
System.out.println("dLarge01 formatted to 5 places: "
|
||||
+ df5Pos.format(dLarge01)); //2c
|
||||
}
|
||||
}
|
||||
/* output:
|
||||
E:\programs\Mod1\Project3>java DecFormat
|
||||
dLarge01 formatted to 3 places: 00.154
|
||||
dLarge01 formatted to 5 places: 00.1535
|
||||
*/
|
||||
@@ -0,0 +1,54 @@
|
||||
/******************************************************************************
|
||||
* Project: Project 3c *
|
||||
* Class Name: JOptPane *
|
||||
* Author: Amrit Panesar -ASP ,o/ *
|
||||
* Last Edited: 08/20/2012 *
|
||||
* Hours: 0.25 Hours *
|
||||
* Purpose: To demonstrate the ability to create a conventionally named *
|
||||
* java application, the parsing of numeric strings with *
|
||||
* exception handling, format numeric output using Decimal *
|
||||
* Format, write to and read from a simple text file, use Decimal*
|
||||
* Format to format output *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
import javax.swing.*; //3
|
||||
|
||||
public class JOptPane //3
|
||||
{
|
||||
public static void main(String[] args) //main
|
||||
{
|
||||
String input = JOptionPane.showInputDialog("Please enter a whole number."); //3a
|
||||
int iInt01;
|
||||
try
|
||||
{
|
||||
iInt01 = Integer.parseInt(input); //3b
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "We're sorry, \""+input+"\" was"
|
||||
+ " an incorrect input.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
//3c
|
||||
return;
|
||||
}
|
||||
JOptionPane.showMessageDialog(null, "Your number was: "+iInt01,
|
||||
"Success", JOptionPane.INFORMATION_MESSAGE);// 3d
|
||||
|
||||
/*--double time--*/
|
||||
input = JOptionPane.showInputDialog("Please enter a decimal number."); //3e
|
||||
double dReal01;
|
||||
try
|
||||
{
|
||||
dReal01 = Double.parseDouble(input); //3f
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "We're sorry, \""+input+"\" was"
|
||||
+ " an incorrect input.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
//3g
|
||||
return;
|
||||
}
|
||||
JOptionPane.showMessageDialog(null, "Your number was: "+dReal01,
|
||||
"Success", JOptionPane.INFORMATION_MESSAGE);// 3d
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/******************************************************************************
|
||||
* Project: Project 3a *
|
||||
* Class Name: Project3a *
|
||||
* Author: Amrit Panesar -ASP ,o/ *
|
||||
* Last Edited: 08/20/2012 *
|
||||
* Hours: 1.00 Hours *
|
||||
* Purpose: To demonstrate the ability to create a conventionally named *
|
||||
* java application, the parsing of numeric strings with *
|
||||
* exception handling, format numeric output using Decimal *
|
||||
* Format, write to and read from a simple text file, use Decimal*
|
||||
* Format to format output *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
public class Project3a
|
||||
{
|
||||
public static void main(String[] args) // main
|
||||
{
|
||||
int iNum01 = 1337; //1a
|
||||
int iNum02 = 42; //1a
|
||||
|
||||
double dPow = Math.pow(iNum01, iNum02); //1b1
|
||||
double dSqrt = Math.sqrt(iNum01); //1b2
|
||||
|
||||
System.out.println("The first number is: "+iNum01+".");
|
||||
System.out.println("The second number is: "+iNum02+".");
|
||||
System.out.println(""+iNum01+" raised to the power of "+iNum02+" is: "
|
||||
+ dPow+"."); //1b1
|
||||
System.out.println("The square root of "+iNum01+" is: "+dSqrt+".\n");//1b2
|
||||
|
||||
if (dPow >= dSqrt) //1b3
|
||||
{
|
||||
System.out.println("The first number ("+iNum01+") raised to the "
|
||||
+"second number ("+iNum02+") \nis greater than the square "
|
||||
+"root of ("+iNum01+")."); //1b3
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("The square root of "+iNum01+" is greater than"
|
||||
+ "the first number("+iNum01+") raised to the second number"
|
||||
+ "("+iNum02+")."); //1b3
|
||||
}
|
||||
System.out.println("\n---------------------------------------------\n");
|
||||
|
||||
double dRad = 7; //1b4
|
||||
double dDia = 7*2; //1b4
|
||||
double dArea = Math.PI*(Math.pow(dRad, 2)); //1b4
|
||||
|
||||
System.out.println("Circle's Radius: "+ dRad + "."); //1b4
|
||||
System.out.println("Circle's Diameter: " + dDia + "."); //1b4
|
||||
System.out.println("Circle's Area: "+ dArea + "."); //1b4
|
||||
|
||||
System.out.println("\n---------------------------------------------\n");
|
||||
|
||||
String sQuote= "Now is the time for all good men to come to the aid of "
|
||||
+ "their country."; //1c
|
||||
|
||||
System.out.println("The ammount of characters in the quote \n"
|
||||
+ "\""+sQuote+"\" \nis: "+sQuote.length()+".\n"); //1c1
|
||||
|
||||
System.out.println("The same quote in all caps is: \n"
|
||||
+ "\""+sQuote.toUpperCase()+"\"\n"); //1c2
|
||||
|
||||
System.out.println("The same quote in lower case is: \n"
|
||||
+ "\""+sQuote.toLowerCase()+"\"\n"); //1c3
|
||||
|
||||
System.out.println("The first index of the character 'o' is: "
|
||||
+ sQuote.indexOf('o')+"\n"); //1c4
|
||||
|
||||
System.out.println("The next index of the character 'o' is: "
|
||||
+ sQuote.indexOf('o',(sQuote.indexOf('o')+1))+"\n"); //1c5
|
||||
|
||||
System.out.println("The character present at index 17 is a(n) '"
|
||||
+ sQuote.charAt(17) + "'.\n"); //1c6
|
||||
|
||||
String sSubstr = sQuote.substring(sQuote.indexOf('t'),
|
||||
(sQuote.length()-1)); //1c7
|
||||
|
||||
System.out.println("The substring of the quote from the first instence "
|
||||
+ "of the character 't' \nto the last character, not including "
|
||||
+ "a period is: \n\""+sSubstr+"\""); //1c8
|
||||
}
|
||||
}
|
||||
|
||||
/* output:
|
||||
E:\programs\Mod1\Project3>java Project3a
|
||||
The first number is: 1337.
|
||||
The second number is: 42.
|
||||
1337 raised to the power of 42 is: 1.983896928320167E131.
|
||||
The square root of 1337 is: 36.565010597564445.
|
||||
|
||||
The first number (1337) raised to the second number (42)
|
||||
is greater than the square root of (1337).
|
||||
|
||||
---------------------------------------------
|
||||
|
||||
Circle's Radius: 7.0.
|
||||
Circle's Diameter: 14.0.
|
||||
Circle's Area: 153.93804002589985.
|
||||
|
||||
---------------------------------------------
|
||||
|
||||
The ammount of characters in the quote
|
||||
"Now is the time for all good men to come to the aid of their country."
|
||||
is: 69.
|
||||
|
||||
The same quote in all caps is:
|
||||
"NOW IS THE TIME FOR ALL GOOD MEN TO COME TO THE AID OF THEIR COUNTRY."
|
||||
|
||||
The same quote in lower case is:
|
||||
"now is the time for all good men to come to the aid of their country."
|
||||
|
||||
The first index of the character 'o' is: 1
|
||||
|
||||
The next index of the character 'o' is: 17
|
||||
|
||||
The character present at index 17 is a(n) 'o'.
|
||||
|
||||
The substring of the quote from the first instence of the character 't'
|
||||
to the last character, not including a period is:
|
||||
"the time for all good men to come to the aid of their country"
|
||||
*/
|
||||
@@ -0,0 +1,80 @@
|
||||
/******************************************************************************
|
||||
* Project: Project 3d *
|
||||
* Class Name: TempCon *
|
||||
* Author: Amrit Panesar -ASP ,o/ *
|
||||
* Last Edited: 08/23/2012 *
|
||||
* Hours: 1.50 Hours *
|
||||
* Purpose: To demonstrate the ability to create a conventionally named *
|
||||
* java application, the parsing of numeric strings with *
|
||||
* exception handling, format numeric output using Decimal *
|
||||
* Format, write to and read from a simple text file, use Decimal*
|
||||
* Format to format output *
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class TempCon
|
||||
{
|
||||
public static void main(String[] args) // main
|
||||
{
|
||||
String sCity = JOptionPane.showInputDialog("Please enter a city."); //4a
|
||||
sCity = sCity.toUpperCase();//4b
|
||||
|
||||
String sDate = JOptionPane.showInputDialog("Please enter a date, mm/dd/yyyy."); //4c
|
||||
|
||||
String sTemp = JOptionPane.showInputDialog("Please enter a temperature in Fahrenheit."); //4d
|
||||
double dTemp = 0;
|
||||
try
|
||||
{
|
||||
dTemp = Double.parseDouble(sTemp);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "We're sorry, \""+dTemp+"\" was an invalid input"
|
||||
+"Please re-run the application.", "Fatal Error", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(0);
|
||||
}
|
||||
double dTempc = (dTemp - 32) * (5.0/9.0);
|
||||
String sTempc = String.format("%.2f", dTempc);
|
||||
|
||||
PrintWriter outFile = null;
|
||||
Scanner inFile = null;
|
||||
try
|
||||
{
|
||||
outFile = new PrintWriter("tempfile.dat");
|
||||
inFile = new Scanner(new FileReader("tempfile.dat"));
|
||||
String sOut = "Temperature for: "+sCity+"\non: "+sDate+"\n"
|
||||
+dTemp+"\u00B0 Fahrenheit\n"+sTempc+"\u00B0 Celsius.";
|
||||
String sIn = "";
|
||||
|
||||
outFile.append(sOut);
|
||||
outFile.flush();
|
||||
sIn = inFile.nextLine() + "\n" + inFile.nextLine() + "\n" +
|
||||
inFile.nextLine() + "\n" + inFile.nextLine();
|
||||
|
||||
JOptionPane.showMessageDialog(null,sIn, "Temperature for: "+sCity,
|
||||
JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "We're sorry, please make a file named "
|
||||
+"Tempfile.dat", "Fatal Error", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(0);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "We're sorry, caught an I/o exception "
|
||||
,"Fatal Error", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(0);
|
||||
}
|
||||
finally
|
||||
{
|
||||
outFile.close();
|
||||
inFile.close();
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
Temperature for: EL CAJON
|
||||
on: 01/10/1990
|
||||
-212.0° Fahrenheit
|
||||
-135.56° Celsius.
|
||||
Reference in new issue
Block a user