Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
80 views

Java

This document contains code for 5 JavaFX applications that create simple user interfaces. The first application displays a text string in a window. The second creates a form with two text fields. The third adds functionality to update a label when the text fields change. The fourth adds buttons that update a label when clicked. The fifth expands on this with additional fields and layout.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views

Java

This document contains code for 5 JavaFX applications that create simple user interfaces. The first application displays a text string in a window. The second creates a form with two text fields. The third adds functionality to update a label when the text fields change. The fourth adds buttons that update a label when clicked. The fifth expands on this with additional fields and layout.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 26

/*

* To change this license header, choose License Headers in Project Properties.


* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javafxapplication1;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
*
* @author pc-daryong
*/
public class JavaFXApplication1 extends Application {

public static void main(String[] args)


{
Application.launch(args);
}

@Override
public void start(Stage stage)
{

Text text = new Text ("Hello JavaFX");

VBox root = new VBox();


root.getChildren().add(text);
root.setMinSize(350, 250);

Scene scene = new Scene(root);

stage.setX(100);
stage.setX(200);
stage.setMinHeight(300);
stage.setMinWidth(400);

stage.setScene(scene);
stage.setTitle("Your first JavaFX Example");
stage.show();

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javafxapplication2;
import javafx.application.Application;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

/**
*
* @author pc-daryong
*/
public class JavaFXApplication2 extends Application
{
public static void main(String[] args)
{
Application.launch(args);
}

@Override
public void start(Stage stage)
{

TextField firstNameFld = new TextField();


TextField lastNameFld = new TextField();

Label firstNameLbl = new Label("_First Name:");


Label lastNameLbl = new Label("_Last Name:");

firstNameLbl.setLabelFor(firstNameFld);
firstNameLbl.setMnemonicParsing(true);

lastNameLbl.setLabelFor(lastNameFld);
lastNameLbl.setMnemonicParsing(true);

GridPane root = new GridPane();


root.addRow(0, firstNameLbl, firstNameFld);
root.addRow(1, lastNameLbl, lastNameFld);
root.setMinSize(350, 250);

root.setStyle("-fx-padding: 10;" +
"-fx-border-style: solid inside;" +
"-fx-border-width: 2;" +
"-fx-border-insets: 5;" +
"-fx-border-radius: 5;" +
"-fx-border-color: blue;");

Scene scene = new Scene(root);


stage.setScene(scene);
stage.setTitle("A Label Example");
stage.show();
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javafxapplication3;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.TextField;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

/**
*
* @author pc-daryong
*/
public class JavaFXApplication3 extends Application {
Label messageLbl = new Label("Enter your Name into the Text Fields.");

public static void main(String[] args)


{
Application.launch(args);
}

@Override
public void start(Stage stage) {

TextField firstNameFld = new TextField();


TextField lastNameFld = new TextField();

firstNameFld.setPrefColumnCount(15);
lastNameFld.setPrefColumnCount(15);

firstNameFld.setOnAction((ActionEvent e) -> {
printMessage("You have changed the First Name!");
});
lastNameFld.setOnAction((ActionEvent e) -> {
printMessage("You have changed the Last Name !");
});
GridPane root = new GridPane();
root.setHgap(10);
root.setVgap(5);

root.addRow(0, messageLbl);
root.addRow(1, new Label("First Name:"), firstNameFld);
root.addRow(2, new Label("Last Name:"), lastNameFld);

root.setMinSize(350, 250);

root.setStyle("-fx-padding: 10;" +
"-fx-border-style: solid inside;" +
"-fx-border-width: 2;" +
"-fx-border-insets: 5;" +
"-fx-border-radius: 5;" +
"-fx-border-color: blue;");
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setTitle("A TextField Example");
stage.show();
}
public void printMessage(String message)
{
messageLbl.setText(message);
}
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javafxapplication4;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

/**
*
* @author pc-daryong
*/
public class JavaFXApplication4 extends Application {
Label messageLbl = new Label("Press any Button to see the message.");

public static void main(String[] args)


{
Application.launch(args);
}

@Override
public void start(Stage stage) {

Button newBtn = new Button("_New");


newBtn.setOnAction(new EventHandler<ActionEvant>()
{
public void handle(ActionEvent e)
{
printMessage("You have pressed the new Button");
}

@Override
public void handle(ActionEvent e)
{
throw new UnsupportedOperationException("Not supported yet."); //To
change body of generated methods, choose Tools | Templates.
}
private void printMessage(String you_have_pressed_the_new_Button) {
throw new UnsupportedOperationException("Not supported yet."); //To
change body of generated methods, choose Tools | Templates.
}
});
Button saveBtn = new Button("_Save");
saveBtn.setDefaultButton(true);
saveBtn.setOnAction((ActionEvent e) -> {
printMessage("You have pressed the save Button");
});
Button cancelBtn = new Button("_Cancel");
cancelBtn.setCancelButton(true);
cancelBtn.setOnAction(new EventHandler<ActionEvant>()
{
@Override public void handle(ActionEvent e)
}
printMessage("You have pressed the cancel Button");
}
});
HBox buttonBox = new HBox();
buttonBox.getChildren().addAll(newBtn, saveBtn, cancelBtn);
buttonBox.setSpacing(15);

VBox root = new VBox();


root.getChildren().addAll(messageLbl, buttonBox);
root.setSpacing(15);
root.setMinSize(350, 250);

root.setStyle("-fx-padding: 10;" +
"-fx-border-style: solid inside;" +
"-fx-border-width: 2;" +
"-fx-border-insets: 5;" +
"-fx-border-radius: 5;" +
"-fx-border-color: blue;");

Scene scene = new Scene(root);


stage.setScene(scene);
stage.setTitle("A Button Example");
stage.show();
}
public void printMessage(String message)
{
messageLbl.setText(message);
}
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javafxapplication5;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.scene.control.MenuButton;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.Background;

/**
*
* @author daryong
*/
public class JavaFXApplication5 extends Application {
Label messsageLbl = new Label("Student Information Form");

public static void main(String[]args)


{
Application.launch(args);
}
@Override
public void start(Stage stage)
{
TextField IDFld = new TextField();
TextField firstNameFld = new TextField();
TextField middleNameFld = new TextField();
TextField lastNameFld = new TextField();
TextField contactNumberFld = new TextField();
TextField EmailAddressFld = new TextField();
TextField AddressFld = new TextField();

IDFld.setOnAction((ActionEvent e) -> {
printMessage("You have changed the ID");
});
firstNameFld.setOnAction((ActionEvent e) -> {
printMessage("You have changed the First Name!");
});
middleNameFld.setOnAction((ActionEvent e) -> {
printMessage("You have changed the Middle Name!");
});
lastNameFld.setOnAction((ActionEvent e) -> {
printMessage("You have changed the Last Name!");
});
contactNumberFld.setOnAction((ActionEvent e) -> {
printMessage("You have changed the Contact Number!");
});
EmailAddressFld.setOnAction((ActionEvent e) -> {
printMessage("You have changed the EmailAddress!");
});
AddressFld.setOnAction((ActionEvent e) -> {
printMessage("You have changed the Address!");
});

firstNameFld.setPrefColumnCount(15);
middleNameFld.setPrefColumnCount(15);
lastNameFld.setPrefColumnCount(15);
contactNumberFld.setPrefColumnCount(15);
EmailAddressFld.setPrefColumnCount(25);
AddressFld.setPrefColumnCount(25);

Label studentIdLbl = new Label("_Student ID: ");


Label firstNameLbl = new Label ("_First Name: ");
Label middleNameLbl = new Label ("_Middle Name: ");
Label lastNameLbl = new Label ("_Last Name: ");
Label contactNumberLbl = new Label ("_Contact Number: ");
Label EmailAddressLbl = new Label ("_Email Address: ");
Label AddressLbl = new Label ("_Address: ");

studentIdLbl.setLabelFor(IDFld);
studentIdLbl.setMnemonicParsing(true);

firstNameLbl.setLabelFor(firstNameFld);
firstNameLbl.setMnemonicParsing(true);

middleNameLbl.setLabelFor(middleNameFld);
middleNameLbl.setMnemonicParsing(true);

lastNameLbl.setLabelFor(lastNameFld);
lastNameLbl.setMnemonicParsing(true);

contactNumberLbl.setLabelFor(contactNumberFld);
contactNumberLbl.setMnemonicParsing(true);

EmailAddressLbl.setLabelFor(EmailAddressFld);
EmailAddressLbl.setMnemonicParsing(true);

AddressLbl.setLabelFor(AddressFld);
AddressLbl.setMnemonicParsing(true);

Button newBtn = new Button("_New");


newBtn.setDefaultButton(true);
newBtn.setPrefSize(150,100);

newBtn.setOnAction((ActionEvent e) -> {
printMessage("You have pressed the new button");
});

Button saveBtn = new Button("_Save");


saveBtn.setDefaultButton(true);
saveBtn.setPrefSize(150,100);
saveBtn.setOnAction((ActionEvent e) -> {
printMessage("You have pressed the save button");
});

Button cancelBtn = new Button("_Cancel");


cancelBtn.setDefaultButton(true);
cancelBtn.setPrefSize(150,100);
cancelBtn.setOnAction((ActionEvent e) -> {
printMessage("You have pressed the cancel button");
});

MenuItem ford = new MenuItem("ford");


MenuItem audi = new MenuItem("audi");
MenuItem ferrari = new MenuItem("ferrari");
MenuItem porsche = new MenuItem("porsche");
MenuButton cars = new MenuButton("Select");
cars.getItems().addAll(ford,audi,ferrari,porsche);

GridPane root = new GridPane();


root.setHgap(90);
root.setVgap(10);

root.addRow(3, messsageLbl);
root.addRow(6, studentIdLbl, IDFld);
root.addRow(7, firstNameLbl, firstNameFld);
root.addRow(8, middleNameLbl,middleNameFld);
root.addRow(9, lastNameLbl, lastNameFld);
root.addRow(6,contactNumberLbl, contactNumberFld);
root.addRow(7, EmailAddressLbl, EmailAddressFld);
root.addRow(8, AddressLbl, AddressFld);
root.addRow(13, newBtn, saveBtn, cancelBtn);
root.addRow(11, cars);
root.setMinSize(450,450);

root.setStyle("-fx-padding: 100;" + "-fx-border-style: solid inside;" + "-


fx-borderwidth: 5;" + "-fx-border-insets: 5;" + "-fx-border-radius: 10;" + "-fx-
border-color: black;");

Scene scene = new Scene(root);


stage.setScene(scene);
stage.setTitle("Student Information Form");
stage.show();

root.setStyle("-fx-padding: 50;" + "-fx-border-style: solid inside;" + "-


fx-border-width: 50;" + "-fx-border-insets: 5;" + "-fx-border-radius: 5;" + "-fx-
border-color:violet");

private void printMessage(String you_have_changed_the_ID) {


throw new UnsupportedOperationException("Not supported yet."); //To change
body of generated methods, choose Tools | Templates.
}
}

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class LabEight {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Input First number: ");
int Firstnumber = in.nextInt();
System.out.print("Input Second number: ");
int Secondnumber = in.nextInt();
System.out.print("Input Third number: ");
int Thirdnumber = in.nextInt();

System.out.println();
if ( Firstnumber > Secondnumber &&Firstnumber > Thirdnumber )
{
System.out.println("Fistnumber is Largest");
}
else if
( Secondnumber > Thirdnumber && Secondnumber > Firstnumber)
{
System.out.println("Secondnumber is Largest");
}
else if ( Thirdnumber > Firstnumber && Thirdnumber > Secondnumber )
{
System.out.println("Thirdnumber is Largest");
}

}
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
import java.util.Scanner;
public class LabFive {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Input Hours: ");
int Hours = in.nextInt();
System.out.print("Input Minutes: ");
int Minutes = in.nextInt();
System.out.print("Total Minutes: ");
System.out.println(Hours * 60 + Minutes);
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
import java.util.Scanner;
public class LabFour {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Input length: ");
int length = in.nextInt();
System.out.print("Input widtth: ");
int width = in.nextInt();
System.out.println(2*length+2*width);
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class LabNine {
public static void main(String[] args){

}
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
import java.util.Scanner;
public class LabOne {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Input first number: ");
int num1 = in.nextInt();
System.out.print("Input Second number: ");
int num2 = in.nextInt();
System.out.println(num1+("+")+num2+"="+(num1+num2));
System.out.println(num1+"x"+num2+"="+num1*num2);
System.out.println(num1+("-")+num2+"="+(num1-num2));
System.out.println(num1 +("/") + num2 + "=" + num1/num2);
}
}

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class LabSeven {
public static void main(String[] args){
Scanner in= new Scanner(System.in);
System.out.print("Input number: ");
int number = in.nextInt();

System.out.println();
if ( 0 == number % 2)
{
System.out.println("Even");
}
else {
System.out.print("Odd");
}
}
}

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class LabSix {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Input First Integer: ");
int FirstInteger = in.nextInt();
System.out.print("Input Second Integer: ");
int SecondInteger = in.nextInt();
System.out.println();
if ( FirstInteger == SecondInteger )
{
System.out.println("equal");
}
else {

System.out.print("not equal");
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
import java.util.Scanner;
public class LabThree {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Input Celsius: ");
int Celsius = in.nextInt();
System.out.println(Celsius*1.8+32);

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
import java.util.Scanner;
public class LabTwo {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Input KPH: ");
int KPH = in.nextInt();
System.out.println(KPH*0.621371);
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class LoopOne {
public static void main(String args[] ){
int i = 1;
int z = 10;

while (i < z) {
i++;
z--;
System.out.println(i+"/"+z);
}
}
}

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class meal {
public static void main(String[] args){
char food;
double totalcharges= 0.00, charges= 0.00;
int quantity;

String order_food= "None";

Scanner meal= new Scanner(System.in);


System.out.print("Enter Customer`s order: ");
food = meal.next().charAt(0);

if(food != 'b' && food != 'f' && food != 'p' && food != 's')
{
System.out.println("Your order is not available.");
}
else{
System.out.print("Enter quantity: ");
quantity = meal.nextInt();

switch(food){

case 'b':
order_food = quantity + " burger ";
charges = 50.00;
break;
case 'f':
order_food = quantity + " fries ";
charges= 35.00;
break;
case 'p':
order_food = quantity + " pizza ";
charges= 100.00;
break;
case 's':
order_food = quantity + " sandwiches ";
charges= 75.00;
break;
}

System.out.println("Your order is " + order_food + " the total amount is "


+ ((double)quantity * charges));
}

} }

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class Menu {
public static void main(String[] args){

int meal, drinks;


String order_meal = "None";
String order_drinks = "None";

Scanner menu = new Scanner(System.in);


System.out.print("Enter choice for the meal: ");
meal = menu.nextInt();
System.out.print("Enter choice for the drinks: ");
drinks = menu.nextInt();

switch(meal){
case (1):
order_meal = "Chicken";

break;
case (2):
order_meal = "Hotdog";

break;

case (3):
order_meal = "Beef";

break;

case(4):
order_meal = "Vegetables";

break;
}
switch(drinks){

case (1):
order_drinks = "Soda";

break;

case (2):
order_drinks = "IcedTea";

break;

case (3):
order_drinks = "Juice";

break;

case'4':
order_drinks = "Water";

break;
}
System.out.println("Your orders are " + order_meal + " and " + order_drinks
+ ".");
}
}

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class midterm {
public static void main(String[] args){
Scanner in= new Scanner(System.in);
System.out.print("Input number: ");
int number = in.nextInt();

System.out.println();

if ( 0 < number)
{
System.out.println("The number is positive");
}
else if
(number == 0)
{
System.out.println("The number is zero");
}

else {
System.out.println("The number is negative");
}
}
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class Natural {
public static void main(String[] args){
System.out.println("The first 10 natural numbers are: ");
int i = 0;
while(i < 10){
i++;

System.out.println(i);
}
}
}

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author pc-daryong
*/
public class natural2 {
public static void main(String[] args){
Scanner in= new Scanner(System.in);
int number;
System.out.println("Input number: ");
number = in.nextInt();
int sum = 0;
{
int i = 0;
int z = number;
System.out.println("The first n natural numbers are: " + number);

while(i < z){


i++;
System.out.println(i);
sum += i;
}

System.out.println("The sum of Natural Number up to n terms: " + sum);


}
}
}

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class odd {
public static void main(String[] args){

Scanner in = new Scanner(System.in);

System.out.print("Input number: ");


int num = in.nextInt();
System.out.println("The odd numbers are: " );
int sum = 0;
{

int i = 0, z = (num);
int a = num;
while (i < (a+z)){
System.out.println(i+=1);
i++;
sum+=i;
{

}
System.out.print("The Sum of Odd Natural numbers up to " + num + " terms: " +
(sum - (a)));
}
}
}

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class odd22o {
public static void main(String[] args){
Scanner in= new Scanner(System.in);
int num;
System.out.println("Input number: ");
num = in.nextInt();
System.out.println("The odd numbers are: ");
int sum = 0;
{
int i = 0,z = (num);
int a = num;
while(i < (a+z)){
System.out.println(i+=1);
i++;
sum += i;
}

System.out.println("The sum of odd Number up to " + num + " terms: " + (sum
-(a)));

}
}

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author pc-daryong
*/
public class pattern {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.println(" J a v v a");
System.out.println(" J a a v v a a");
System.out.println(" J J aaaaa V V aaaaa");
System.out.println(" JJ a a v a a");

}
}

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class Pattern2 {
public static void main(String[] args){

Scanner in = new Scanner(System.in);


System.out.print("Input First Number: ");
int FirstNum = in.nextInt();
System.out.print("Input Second Number: ");
int SecondNum = in.nextInt();
System.out.print("Input Third Number: ");
int ThirdNum= in.nextInt();
System.out.print("Input Fourth Number: ");
int FourthNum= in.nextInt();

if ( FirstNum == SecondNum && FirstNum == ThirdNum && ThirdNum == FourthNum)


{
System.out.println("Numbers are equal ");
}
else {

System.out.print("Numbers are not equal ");

}
}
}

import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class Pattern3 {
public static void main(String[] args){
Scanner in = new Scanner(System.in);

System.out.println("Input First Number: ");


double x = in.nextDouble();
System.out.print("Input Second Number: ");
double y = in.nextDouble();

if (x > 0 && y > 1)


{
System.out.println("true");
}else
{
System.out.println("false");
}

}
}

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class Pattern4 {
public static void main(String[] args){
Scanner in = new Scanner(System.in);

System.out.print("Input Number of rows: ");


int num = in.nextInt();

for(int i =1; i<= num; i++) {


for (int j =1; j <= i; j++) {
System.out.print(j + "");
}
System.out.println();
}
}
}

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class Pattern5 {
public static void main(String[] args){
Scanner in = new Scanner(System.in);

System.out.print("Input Number of rows: ");


int num = in.nextInt();

for(int i =1; i<= num; i++) {


for (int j =1; j <= i; j++) {
System.out.print(i);
}
System.out.println();
}
}
}

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class Pattern6 {
public static void main(String[] args){
Scanner in = new Scanner(System.in);

System.out.print("Input Number: ");


int num = in.nextInt();

System.out.println();

if ( 0 < num)
{
System.out.println("The number is positive");
}
else if
(num == 0)
{
System.out.println("The number is zero");
}

else {
System.out.println("The number is negative");
}
}
}

import java.util.Arrays;
import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

import java.util.Scanner;

/**
*
* @author pc-daryong
*/

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

import java.util.Scanner;

/**
*
* @author pc-daryong
*/
public class Pattern7 {
public static void main(String[]args){
Scanner in =new Scanner(System.in);
System.out.print("Input Number of Arrays :");
int sum = 0;
String d;
int num = in.nextInt();
int[] Array = new int[num];

for(int i=0;i< Array.length;i++){


System.out.print("Input Number" + (i+1) + ":");

Array[i]=in.nextInt();
sum = sum+Array[i];
}
if ((Array[0] != 2 && Array[0] != 2) )

System.out.println("True");
else if ((Array[0] <= 2 && Array[0] <= 2))
System.out.println("False");

}
}

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class Pattern9 {
public static void main(String[]args){
Scanner in =new Scanner(System.in);
System.out.print("Input Number of Arrays :");

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author pc-daryong
*/
public class zodiac2 {

public static void main(String[] args){


String bm;
int day;

Scanner in = new Scanner(System.in);


System.out.print("Enter your birthmonth: ");
bm = in.nextLine();
System.out.print("Enter your birthday: ");
day = in.nextInt();

if (bm.equalsIgnoreCase("january")){
if (day >0 && day <= 19 ){

System.out.println("Your Zodiac Sign is capricorn");


}else
System.out.println("Your Zodiac Sign is Aquarius");
}

if (bm.equalsIgnoreCase("February")){
if (day >0 && day < 19 ){
System.out.println("Your Zodiac Sign is Aquarius");
} else
System.out.println("Your Zodiac Sign is Pisces");
}

if (bm.equalsIgnoreCase("March")){
if (day >0 && day < 21 ){

System.out.println("Your Zodiac Sign is Pisces");


} else
System.out.println("Your Zodiac Sign is Aries");
}

if (bm.equalsIgnoreCase("April")){
if(day >0 && day < 19 ){

System.out.println("Your Zodiac Sign is Aries");


} else
System.out.println("Your Zodiac Sign is Taurus");
}

if (bm.equalsIgnoreCase("May") ){
if(day >0 && day < 19 ){

System.out.println("Your Zodiac Sign is Taurus");


}else
System.out.println("Your Zodiac Sign is Gemini");
}

if (bm.equalsIgnoreCase("June")){
if (day >0 && day < 19 ){

System.out.println("Your Zodiac Sign is Gemini");


} else
System.out.println("Your Zodiac Sign is Cancer");
}

if (bm.equalsIgnoreCase("July")){
if(day >0 && day < 19 ){

System.out.println("Your Zodiac Sign is Cancer");


} else
System.out.println("Your Zodiac Sign is Leo");
}

if (bm.equalsIgnoreCase("August")){
if(day >0 && day < 19 ){

System.out.println("Your Zodiac Sign is Leo");


}else
System.out.println("Your Zodiac Sign is Virgo");
}

{
if (bm.equalsIgnoreCase("September")){
if(day >0 && day < 19 ){

System.out.println("Your Zodiac Sign is Virgo");


} else
System.out.println("Your Zodiac Sign is Libra");
}

if (bm.equalsIgnoreCase("October")){
if(day >0 && day < 19 ){

System.out.println("Your Zodiac Sign is Libra");


}else
System.out.println("Your Zodiac Sign is Scorpio");
}

if (bm.equalsIgnoreCase("November")){
if(day >0 && day < 19 ){
System.out.println("Your Zodiac Sign is Scorpio");
}else
System.out.println("Your Zodiac Sign is Sagittarius");
}

if (bm.equalsIgnoreCase("December")){
if(day >0 && day < 19 ){

System.out.println("Your Zodiac Sign is Sagittarius");


} else
System.out.println("Your Zodiac Sign is Capricorn");
}

}
}

You might also like