Commit 518bae3a authored by angel.rivera's avatar angel.rivera

GOod

parents
public class App {
public static void main(String[] args) throws Exception {
System.out.println("Hello, World!");
}
}
public class Complex {
public double real;
public double imag;
private static double argument;
public Complex()
{
real = 0;
imag = 0;
}
public Complex(double r, double i)
{
real = r;
imag = i;
double d = Math.atan2(i,r);
}
public double imag()
{
return imag;
}
public double real()
{
return real;
}
public double magnitude()
{
return 1.0;
}
public static void main(String[] args){
Complex myMag = new Complex();
myMag.magnitude();
}
public double argument()
{
return 1.0;
}
public static void main(String[] args){
Complex myArg = new Complex(double r, double i);
myArg.argument();
}
public String toString()
{
return "";
}
public static void main(String[] args){
Complex myString = new Complex();
myString.toString("1.2 + j3.4");
}
public Complex add(Complex complexNum)
{
Complex answer = new Complex(0.0,0.0);
return answer;
}
public static void main(int) {
Comlpex addComplex = new Complex(r + i);
addComplex.Complex();
}
}
\ No newline at end of file
public class Rectangle extends Shape {
public Rectangle() {
super();
}
public Rectangle(int i) {
super(i);
}
@Override
public void draw() {
for (int loop1=0; loop1<size; loop1++){
for (int loop2=loop1; loop2<(size); loop2++) {
System.out.print(" ");
}
System.out.print("/");
for (int loop2=0; loop2<loop1; loop2++){
System.out.print(" ");
}
System.out.println("\\");
}
for (int loop1=0; loop1>size; loop1++){
System.out.print("--");
}
System.out.println("");
}
@Override
public float area() {
float fSize = size;
float area = fSize * fSize;
return area;
}
@Override
public float circumference() {
float fSize = size;
float circ = 2 * (fSize + fSize);
return circ;
}
}
abstract public class Shape {
protected int size;
abstract public void draw();
abstract public float area();
abstract public float circumference();
public int getSize() { return size; }
public void setSize(int size) { this.size = size; }
public int getWidth(int size) {return size;}
public int getHeight(int size) {return size;}
public Shape(){
this.size = 3;
this.size = 4;
}
public Shape(int size){
this.size = size;
}
public static void main(String[] args){
System.out.println();
}
}
public class ShapeSquare{
private int width;
private int area;
int sizeValue;
int unsizableValue;
public ShapeSquare(int value, int differentvalue){
sizeValue = value;
unsizableValue = differentvalue;
}
public static void main(String[] args) {
ShapeSquare mySizeSquare = new ShapeSquare(3,0);
System.out.println(mySizeSquare.sizeValue + mySizeSquare.unsizableValue);
}
}
import java.util.ArrayList;
public class Zoo1 {
public static void main (String[] args) {
ArrayList<String> animals = new ArrayList<String>();
animals.add("Cobra Snake");
animals.add("Lion");
animals.add("Hyena");
animals.add("Cheetah");
animals.add("Tiger");
animals.add("Dolphins");
animals.add("Bald eagle");
animals.add("Parrots");
System.out.println(animals.get(5) + " communicate through sound waves transmitted from their frontal lobe.");
}
}
import java.util.ArrayList;
public class Zoo2 {
public static void main (String[] args) {
ArrayList<String> animalsdetails = new ArrayList<String>();
animalsdetails.add("Cobra Snake are reptile venenous creatures that can kill you with their poison in a matter of 20 minutes ");
animalsdetails.add("Lion is a carnivorous mammmal most of which are native to africa they roar all together in the pack females and males ");
animalsdetails.add("Hyena lie in packs that are led by females ");
animalsdetails.add("Cheetah are the fastest land animal tehy have more acceleration than most sports cars ");
animalsdetails.add("Tigers are the largest wild cat in the world and are solitary hunters ");
animalsdetails.add("Dolphins are intelligent like us as well eat fish and crustaceans");
animaldetails.add("Bald eagle can reach speed of 160km/hr ");
animaldetails.add("Parrots eat with their claws");
System.out.println(animalsdetails);
}
}
import java.util.ArrayList;
public class Zoo3 {
public static void main (String[] args) {
ArrayList<String> animaltype = new ArrayList<String>();
animaltype.add("Lions are mammals");
animaltype.add("Hyena are mammals");
animaltype.add("Cheetah are mammals");
animaltype.add("Tigers are mammals");
System.out.println(animaltype);
}
}
import java.util.ArrayList;
public class Zoo4 {
public static void main (String[] args) {
ArrayList<String> foodtype = new ArrayList<String>();
foodtype.add("Cobra snakes eat mice and other types of snakes as well smaller cobra snakes. ");
foodtype.add("Lions eat small to medium size large hoofed animals like zebras.");
foodtype.add("Hyenas are scavengers that eat leftovers but also hunt for antelopes.");
foodtype.add("Cheetahs eat small antelopes.");
foodtype.add("Tigers eat large prey like deer and wild boar.");
foodtype.add("Dolphins eat small fish as well as squid and mackerel.");
foodtype.add("Bald Eagle eat fish");
foodtype.add("Parrots eat fresh fruits");
System.out.println(foodtype);
}
}
import java.util.ArrayList;
public class Zoo5 {
public static void main (String[] args) {
ArrayList<String> animalsenvironment = new ArrayList<String>();
animalsenvironment.add("Cobra snakes are form the sub-saharan africa");
animalsenvironment.add("Lions are from the sub-saharan africa");
animalsenvironment.add("Hyenas are from the sub- saharan africa");
animalsenvironment.add("Cheetahs are from the sub-saharan africa");
System.out.println(animalsenvironment);
}
}
public class bankaccount {
// bank account attributes
static int accountSerialNumber;
static String accountName;
double balance;
// contructor method
public bankaccount() {
accountSerialNumber = 12345;
accountName = "Ben";
balance = 2100;
}
// deposit method
public void deposit(double amount) {
balance = balance + amount;
}
// withdraw method
public void withdraw(double amount) {
if (amount <= balance) {
balance = balance - amount;
// overdraft method
} else if (amount > balance && balance > -100) {
System.out.println("Overdraft limit reached.");
balance = -100;
}
}
// bank fee method
public double bankFee() {
double fee = balance * .05;
balance = balance - fee;
return balance;
}
// display method
public void displayAccountDetails() {
System.out.println("Account Number: " + accountSerialNumber + "\n");
System.out.println(accountName + ": $" + balance);
}
public static void main(String[] args) {
bankaccount bensAccount = new bankaccount();
bensAccount.deposit(200);
bensAccount.bankFee();
bensAccount.withdraw(2000);
bensAccount.displayAccountDetails();
}
}
}
public class savingAccount {
// bank account attributes
static int accountSerialNumber;
static String accountName;
double balance;
// contructor method
public savingAccount() {
accountSerialNumber = 12345;
accountName = "Ben";
balance = 2100;
}
// deposit method
public void deposit(double amount) {
balance = balance + amount;
}
// withdraw method
public void withdraw(double amount) {
if (amount <= balance) {
balance = balance - amount;
} else {
System.out.print("Insufficient Funds");
}
}
// bank fee method
public double bankFee() {
double fee = balance * .05;
balance = balance - fee;
return balance;
}
// display method
public void displayAccountDetails() {
System.out.println("Account Number: " + accountSerialNumber + "\n");
System.out.println(accountName + ": $" + balance);
}
// interest method
public int accrueInterest() {
int interest = (int) (balance * .05);
balance = balance + interest;
return (int) balance;
}
public static void main(String[] args) {
savingAccount bensAccount = new savingAccount();
bensAccount.deposit(200);
bensAccount.withdraw(50);
bensAccount.accrueInterest();
bensAccount.bankFee();
bensAccount.displayAccountDetails();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment