Archives from S:\ Drive
Good to keep around methinks
This commit is contained in:
1 parent
eadaf70b9e
commit
6dd63cc439
606 files changed
+50212
No files matched your search
@@ -0,0 +1,102 @@
|
||||
/******************************************************************************
|
||||
* Project: Point 1 *
|
||||
* Class Name: point1 *
|
||||
* Author: Amrit Panesar -ASP ,o/ *
|
||||
* Last Edited: 09/05/2012 *
|
||||
* Hours: 0.50 Hours *
|
||||
* Purpose: Blah. *
|
||||
******************************************************************************/
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class point1
|
||||
{
|
||||
public static void main(String[] args) //main
|
||||
{
|
||||
String sMessage01 = "This application will accept the input of the "
|
||||
+ "lengths of the sides of a triangle and determine if it is a right triangle.\n"
|
||||
+ "A triangle is a polygon with 3 sides and three angles.\n"
|
||||
+ "A triangle is considered right if one of the angles is 90 degrees.";
|
||||
String sMessage02 = "This program will determine weather or not a triangle is right.";
|
||||
|
||||
JOptionPane.showMessageDialog(null, sMessage01, "Welcome",
|
||||
JOptionPane.PLAIN_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, sMessage02, "Welcome",
|
||||
JOptionPane.PLAIN_MESSAGE);
|
||||
String input = JOptionPane.showInputDialog("Please enter a side length.");
|
||||
double dSide01 = 0;
|
||||
try
|
||||
{
|
||||
dSide01 = Double.parseDouble(input);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "We're sorry, \""+input+"\" was"
|
||||
+ " an incorrect input.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(0);
|
||||
}
|
||||
if (dSide01 < 0)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "We're sorry, you cannot have a "
|
||||
+ "negative side length.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(0);
|
||||
}
|
||||
input = JOptionPane.showInputDialog("Please enter a side length.");
|
||||
double dSide02 = 0;
|
||||
try
|
||||
{
|
||||
dSide02 = Double.parseDouble(input);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "We're sorry, \""+input+"\" was"
|
||||
+ " an incorrect input.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(0);
|
||||
}
|
||||
if (dSide02 < 0)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "We're sorry, you cannot have a "
|
||||
+ "negative side length.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(0);
|
||||
}
|
||||
input = JOptionPane.showInputDialog("Please enter a side length.");
|
||||
double dSide03 = 0;
|
||||
try
|
||||
{
|
||||
dSide03 = Double.parseDouble(input);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "We're sorry, \""+input+"\" was"
|
||||
+ " an incorrect input.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(0);
|
||||
}
|
||||
if (dSide03 < 0)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "We're sorry, you cannot have a "
|
||||
+ "negative side length.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(0);
|
||||
}
|
||||
// big ugly boolean.
|
||||
// IF (intFirstSide * intFirstSide == intSecondSide * intSecondSide + intThirdSide * intThirdSide) ||
|
||||
// (intSecondSide * intSecondSide == intFirstSide * intFirstSide + intThirdSide * intThirdSide)||
|
||||
// (intThirdSide * intThirdSide == intFirstSide * intFirstSide + intSecondSide * intSecondSide)
|
||||
|
||||
dSide01 = Math.pow(dSide01, 2);
|
||||
dSide02 = Math.pow(dSide02, 2);
|
||||
dSide03 = Math.pow(dSide03, 2);
|
||||
if ((dSide01 == (dSide02 + dSide03)) ||
|
||||
(dSide02 == (dSide01 + dSide03)) ||
|
||||
(dSide03 == (dSide01 + dSide02)))
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "This is a right triangle.",
|
||||
"Thank You", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "This is NOT a right triangle.",
|
||||
"Thank You", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/******************************************************************************
|
||||
* Project: Point 2 *
|
||||
* Class Name: point2 *
|
||||
* Author: Amrit Panesar -ASP ,o/ *
|
||||
* Last Edited: 09/05/2012 *
|
||||
* Hours: 0.50 Hours *
|
||||
* Purpose: Blah. *
|
||||
******************************************************************************/
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class point2
|
||||
{
|
||||
public static void main(String[] args) //main
|
||||
{
|
||||
String sMessage01 = "This application will accept the input of the "
|
||||
+ "ammount of cookies the user has to organize into boxes and containers.\n"
|
||||
+ "A box contains 24 cookies.\n"
|
||||
+ "A container contains 75 boxes.";
|
||||
String sMessage02 = "This program will output the ammount of boxes, containers, and the underflow.";
|
||||
JOptionPane.showMessageDialog(null, sMessage01, "Welcome",
|
||||
JOptionPane.PLAIN_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, sMessage02, "Welcome",
|
||||
JOptionPane.PLAIN_MESSAGE);
|
||||
String input = JOptionPane.showInputDialog("Please enter the ammount of cookies.");
|
||||
double dSide01 = 0;
|
||||
try
|
||||
{
|
||||
dSide01 = Double.parseDouble(input);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "We're sorry, \""+input+"\" was"
|
||||
+ " an incorrect input.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(0);
|
||||
}
|
||||
if (dSide01 < 0)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "We're sorry, you cannot have a "
|
||||
+ "negative ammount of cookies.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
String sOutMessage = "";
|
||||
Double dBoxes = dSide01 %24;
|
||||
Double dContainers = dBoxes %75;
|
||||
|
||||
int iContainers = (int) Math.floor(dContainers);
|
||||
if (dContainers > iContainers)
|
||||
iContainers++;
|
||||
|
||||
int iBoxes = (int) Math.floor(dBoxes);
|
||||
if (dBoxes > iBoxes)
|
||||
iBoxes++;
|
||||
|
||||
int iFullContainer = (int) Math.floor(dContainers);
|
||||
int iFullBoxes = iFullContainer * 75;
|
||||
int iLeftOverBoxes = iBoxes - iFullBoxes;
|
||||
int iLeftOverCookies = iLeftOverBoxes * 24;
|
||||
boolean bUnderFlow = false;
|
||||
|
||||
sOutMessage += "You have a total of %d boxes with %d containers.\n";
|
||||
if (iContainers > dContainers)
|
||||
{
|
||||
sOutMessage += "The last container is not full.\n";
|
||||
bUnderFlow = true;
|
||||
}
|
||||
|
||||
if(bUnderFlow)
|
||||
{
|
||||
sOutMessage += "You have %d boxes in the last container, with %d cookies.";
|
||||
System.out.format(sOutMessage, iBoxes, iContainers, iLeftOverBoxes, iLeftOverCookies);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.format(sOutMessage, iBoxes, iContainers);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user