This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void printTicket(int destinationNumber) // method signature, method name, public - accessibility | |
// of the method from external classes | |
{ | |
if (destinationNumber == 1) { | |
if (balance < price1) { | |
System.out.println("Please insert " + (price1 - balance) + " more dollars."); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Program { | |
public static void main(String[] args) { | |
//Declare person objects here | |
Person person1 = new Person("Nikhil Dewars",40 , "MIS", 3.9); | |
Person person2 = new Person("Mark Budweiser",23 , "MIS", 3.2); | |
Person person3 = new Person("Craig Appletons",25 , "MIS", 3.0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Session1 { | |
public static void main(String[] args) { | |
System.out.println("A"); | |
System.out.println("B"); | |
int total = sum(5, 10); | |
System.out.println("The sum is " + total); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class NegativeOrPositive { | |
public static void main (String [] args) { | |
String condStr; | |
int userVal; | |
userVal = -9; | |
condStr = (userVal >= 0)?"non-negative":"negative"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class CharMatching { | |
public static void main (String [] args) { | |
String userInput = ""; | |
char firstLetter = '-'; | |
userInput = "banana"; | |
firstLetter = 'b'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Portfolio { | |
public static void main(String[] args) { | |
double portfolioValue = 0.0; | |
Stock appl = new Stock("Apple", 1000, 50.0); | |
Stock ge = new Stock("General Electric", 1001, 51.0); | |
Stock gm = new Stock("General Motors", 2001, 25.0); | |
Stock amzn = new Stock("Amazon", 10000, 500.0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class BillCalc { | |
public static void main(String[] args) { | |
//Declare variables to be used (billAmount, nosOfDiners) | |
int billAmount = 0; | |
int nosOfDiners = 0; | |
Scanner scnr = new Scanner(System.in); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created by Vivek Narang, 1/3/2018 4:33 AM EST | |
// A JavaScript function that takes in two arguments (Hex color codes) and returns the average of those ... | |
function avgColor(c1, c2) { | |
// Extract the R/G/B parts from the first argument ... | |
var c111 = parseInt(c1.substr(4, 2), 16); | |
var c121 = parseInt(c1.substr(2, 2), 16); | |
var c131 = parseInt(c1.substr(0, 2), 16); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
public class Compute { | |
int[] numbers; | |
int min = Integer.MAX_VALUE; | |
int max = Integer.MIN_VALUE; | |
double mean = 0.0; | |
public Compute(int[] numbers) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
int[][] arr = { { 0, 5 }, { 10, 25 }, { 30, 10 }, { 30, 5 }, { 299, 5 }, { 299, 1 } }; | |
try { | |
new Engine(arr); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} |