# Assignment

Topics: Circle, Radius, 10000 Pages: 16 (1642 words) Published: June 24, 2013
|
Object–Oriented Programming|
Assignment|
|
|

HNDC 12/02 GROUP 2|

Question 1
import javax.swing.JOptionPane;

public class Question1
{
final static double PI = 3.14159;
public static void main(String[] args)
{
String str = "";

circumference = 2 * PI * radius;

JOptionPane.showMessageDialog(null, str + String.format("The area for the circle of radius " + radius + " is " +area));
JOptionPane.showMessageDialog(null, str + String.format("The diameter for the circle of radius " + radius + " is " +diameter));
JOptionPane.showMessageDialog(null, str + String.format("The circumference for the circle of radius " + radius + " is " + circumference));
}
}

The Output

Question 2
import javax.swing.JOptionPane;
public class Question2
{
public static void main( String args[] )
{
int number;
int digit1;
int digit2;
int digit3;
int digit4;
int digit5;
String str = "";
number = Integer.parseInt(JOptionPane.showInputDialog( "Enter five digit integer: " ));

digit1 = number / 10000;
digit2 = number % 10000 / 1000;
digit3 = number % 10000 % 1000 / 100;
digit4 = number % 10000 % 1000 % 100 / 10;
digit5 = number % 10000 % 1000 % 100 % 10;

JOptionPane.showMessageDialog(null, String.format("%d %d %d %d %d\n", digit1, digit2, digit3, digit4, digit5 ));
}
}

The Output

Question 3
import javax.swing.JOptionPane;
public class Question3
{
public static void main(String[] args)
{
int x;
x = Integer.parseInt(JOptionPane.showInputDialog("Enter the number whether the number is even or odd: ")); numberinteger(x);
}
public static void numberinteger(int x){
if(x % 2 == 0)
{
JOptionPane.showMessageDialog(null, "The number is even");
}
else
{
JOptionPane.showMessageDialog(null, "The number is odd");
}
}
}

The Output

Question 4
import javax.swing.JOptionPane;
public class Question4 {
public static void main (String [] args) {

String Name[] = new String [3];
double grosspay [] = new double [3];

double tosalaries = 0.0;
int working_hours, overtime;
int normal_hours;
double hourly_rate;

for (int i = 0; i < 3; i++) {
Name [ i ] = JOptionPane.showInputDialog("Enter the employee's name: ");

hourly_rate = Double.parseDouble(JOptionPane.showInputDialog("Enter working rate per hour: ")); working_hours = Integer.parseInt(JOptionPane.showInputDialog("Enter working hours: "));

overtime = working_hours - 40;
if (overtime < 0) {
overtime = 0;
}
normal_hours = working_hours - overtime;
double normalrate = normal_hours * hourly_rate;
double overtimerate = 1.5 * hourly_rate * overtime;
grosspay [ i ] = normalrate + overtimerate;

tosalaries += grosspay [ i ];
}

String message = "";
for (int i = 0; i < 3; i++) {
message += Name [ i ] + ": \$" +grosspay [ i ] + "\n";
}
message += "Final Total: \$" +tosalaries;
JOptionPane.showMessageDialog(null, message);
}

}

The Output

Question 5
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.awt.*;
import java.util.Scanner;
import javax.swing.JOptionPane;

public class Question5
{
public static void main(String[] args)
{

String[] ID = new String[5];
String[] Brand = new String[5];
String[] Type = new String[5];
String[] Price = new String[5];

ID[0] = "00001";
ID[1] = "00002";
ID[2] = "00003";
ID[3] = "00004";
ID[4] = "00005";

Brand[0] = "Rebecca Minkoff";
Brand[1] = "Gucci";
Brand[2] = "Louis Vuitton";
Brand[4] = "Chanel";

Type[0] = "Tote";
Type[1] = "Shoulder Bag";
Type[2] = "Hobo";
Type[3] = "Satchel";
Type[4] = "Clutch";

Price[0] = "149.00";...