This file contains hidden or 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
| class Sum { | |
| public static void main(String[] args) { | |
| int i = 0, sum = 0; | |
| // Loop adds numbers 1 = 100 | |
| while(i < 100){ | |
| i++; | |
| sum += i; | |
| } |
This file contains hidden or 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; | |
| import java.text.*; | |
| public class Payroll{ | |
| public static void main(String []args){ | |
| double hourPay, hourWorked; | |
| double overtime, total; | |
This file contains hidden or 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; | |
| import java.text.*; | |
| public class Tax { | |
| public static void main(String[] args) | |
| { | |
| // Declare variables | |
| int allowedDeduction = 10000, deduction = 2000; | |
| int grossIncome, dependents; |
This file contains hidden or 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; | |
| import java.text.*; | |
| public class Sphere | |
| { | |
| public static void main(String[] args) | |
| { | |
| double pi = Math.PI; | |
| double radius, volume, surfaceArea; |
This file contains hidden or 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.*; | |
| public class Usernames { | |
| public static void main(String[] args) { | |
| String first, last, username; | |
| int randomNum; | |
| // Scan in first and last name |
This file contains hidden or 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.*; | |
| public class Distance | |
| { | |
| public static void main(String[] args) | |
| { | |
| int x1, y1; | |
| int x2, y2; | |
| int inside, distance; | |
This file contains hidden or 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 Cubes | |
| { | |
| public static void main(String[] args) | |
| { | |
| // Declare variables | |
| double cube1, cube2; | |
| double sum; | |
This file contains hidden or 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 StringManips | |
| { | |
| public static void main (String[] args) | |
| { | |
| String phrase = new String ("This is a String test."); | |
| int phraseLength; // number of characters in the phrase String | |
| int middleIndex; // index of the middle character in the String | |
| String firstHalf; // first half of the phrase String |
This file contains hidden or 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.*; | |
| public class Phone | |
| { | |
| public static void main(String[] args) | |
| { | |
| int num1, num2, num3; //3 numbers in area code | |
| int set2, set3; //sequence 2 and 3 of the phone number | |
| Random generator = new Random(); |
This file contains hidden or 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.*; | |
| public class Lottery | |
| { | |
| public static void main(String []args) | |
| { | |
| // 6 Lottery numbers | |
| int num1, num2, num3, num4, num5, num6; | |
| // Random number generator |