Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- System.out.print("Hello Brighton");
- }
- }
- public class Main
- {
- public static void main(String[] args)
- {
- double mark;
- System.out.println("#Input cw");
- int cw = BIO.getInt();
- System.out.println("#Input ex");
- int ex = BIO.getInt();
- mark = (cw + ex) / 2.0;
- System.out.printf("ex = %d cw = %d mark = %.1f \n", ex, cw, mark);
- }
- }
- public class Main extends BIO
- {
- public static void main(String[] args)
- {
- double mark;
- System.out.println("#Input Student Number");
- int sn = BIO.getInt();
- while (sn > 0)
- {
- System.out.println("#Input ex");
- int ex = BIO.getInt();
- System.out.println("#Input cw");
- int cw = BIO.getInt();
- mark = (ex + cw) / 2.0;
- System.out.printf("sn = %d ex = %d cw = %d mark = %.1f \n", sn, cw, ex, mark);
- System.out.println("#Input Student Number");
- sn = BIO.getInt();
- }
- }
- }
- public class Main
- {
- public static void main(String[] args)
- {
- System.out.print("#Enter size of square: ");
- int size = BIO.getInt();
- int line = 1;
- while (line <= size)
- {
- int stars = 1;
- while (stars <= size)
- {
- System.out.print("*");
- stars++;
- }
- System.out.println();
- line++;
- }
- }
- }
- class Main
- {
- public static void main (String args[])
- {
- System.out.println("#Input square size: ");
- int size = BIO.getInt();
- for (int row=1; row<=size; row++)
- {
- for(int col=1; col<=size; col++)
- {
- if (row==1 || row==size || col==1 || col==size)
- {
- System.out.printf("*");
- }
- else
- {
- System.out.printf(".");
- }
- }
- System.out.println();
- }
- }
- }
- class Main
- {
- public static void main (String args[])
- {
- System.out.print("#Please enter you name: ");
- String name = BIO.getString();
- while (!name.equals("END"))
- {
- System.out.print("#Please enter your module mark: ");
- int mark = BIO.getInt();
- if (mark >= 40)
- {
- String result = ("Pass");
- System.out.printf("%s %s\n", name , result);
- }
- else
- {
- String result = ("Fail");
- System.out.printf("%s %s\n", name, result);
- }
- System.out.print("#Please enter you name: ");
- name = BIO.getString();
- }
- }
- }
- class Main
- {
- public static void main (String args[])
- {
- String name, result;
- int mark;
- System.out.print("#Please enter you name: ");
- name = BIO.getString();
- while (!name.equals("END"))
- {
- System.out.print("#Please enter your module mark: ");
- mark = BIO.getInt();
- if (mark >= 70)
- {
- result = "gains a 1st";
- }
- else if (mark < 70 && mark >= 60)
- {
- result = "gains a 2.1";
- }
- else if (mark < 60 && mark >= 50)
- {
- result = "gains a 2.2";
- }
- else if (mark < 50 && mark >= 40)
- {
- result = "gains a 3rd";
- }
- else
- {
- result = "fails";
- }
- System.out.printf("%s [%d] %s\n", name, mark, result);
- System.out.print("#Please enter you name: ");
- name = BIO.getString();
- }
- }
- }
- public class Main
- {
- public static void main (String args[])
- {
- String name;
- int cmark;
- int emark;
- double omark;
- System.out.print("#Please enter you name: ");
- name = BIO.getString();
- while (!name.equals("END"))
- {
- System.out.print("#Please enter your coursework mark: ");
- cmark = BIO.getInt();
- System.out.print("#Please enter your exam mark: ");
- emark = BIO.getInt();
- omark = (cmark + emark) / 2.0;
- String result;
- if (omark >= 40 && cmark >= 30 && emark >= 30)
- {
- result = "Pass";
- System.out.printf("%s [%d , %d] %.1f %s\n", name, cmark, emark, omark, result);
- }
- else if (omark < 40)
- {
- result = "Fail";
- System.out.printf("%s [%d , %d] %.1f %s\n", name, cmark, emark, omark, result);
- }
- else if (omark >= 40 && cmark >= 30 || emark >= 30)
- {
- result = "Fail [Threshold]";
- System.out.printf("%s [%d , %d] %.1f %s\n", name, cmark, emark, omark, result);
- }
- System.out.print("#Please enter your name: ");
- name = BIO.getString();
- }
- }
- }
- class Main extends BIO {
- public static void main (String args[]) {
- System.out.println("#Please enter size of diamond: ");
- int sod = BIO.getInt();
- int middle;
- int count;
- if (sod % 2 != 0 && sod > 4 && sod < 42) {
- middle = sod/2;
- //line 1
- for(int i = 0; i < middle; i++){
- System.out.print(".");
- }
- System.out.print("*");
- for (int i = 0; i < middle; i++){
- System.out.print(".");
- }
- System.out.println();
- //1.st middle part
- for(int row = 1; row < middle+1; row++){
- for (int i = 0; i < (middle-row); i++){
- System.out.print(".");
- }
- System.out.print("*");
- for (int i = 0; i < (row*2-1); i++){
- System.out.print(".");
- }
- System.out.print("*");
- for (int i = 0; i < (middle-row); i++){
- System.out.print(".");
- }
- System.out.println();
- }
- //2.nd middle
- count = sod - 4;
- for(int row=1;row<middle;row++){
- for (int i = 0; i < row; i++){
- System.out.print(".");
- }
- System.out.print("*");
- for(int i = 0; i<count; i++){
- System.out.print(".");
- }
- count = count - 2;
- System.out.print("*");
- for (int i = 0; i < row; i++){
- System.out.print(".");
- }
- System.out.println();
- }
- // last line
- for(int i = 0; i < middle; i++){
- System.out.print(".");
- }
- System.out.print("*");
- for (int i = 0; i < middle; i++){
- System.out.print(".");
- }
- System.out.println();
- }
- else if (sod < 5 || sod > 41){
- System.out.println("Side of diamond " + "(" + sod + ")" + " must be between 5 & 41");
- }
- else {
- System.out.println("Side of diamond " + "(" + sod + ")" + " must be odd");
- }
- }
- }
- class Main extends BIO {
- public static void main(String args[]) {
- System.out.println("Amount Coins");
- System.out.print("#Enter amount: ");
- int input = BIO.getInt();
- while (input != 0) {
- int amount = input;
- if (input >= 1 && input <= 500) {
- //calculate 200ps
- int i200 = input / 200;
- int a200 = 0;
- while (i200 >= 1) {
- a200++;
- input = input - 200;
- i200 = (input / 200);
- }
- //calculate 100ps
- int i100 = input / 100;
- int a100 = 0;
- while (i100 >= 1) {
- a100++;
- input = input - 100;
- i100 = (input / 100);
- }
- //calculate 50ps
- int i50 = input / 50;
- int a50 = 0;
- while (i50 >= 1) {
- a50++;
- input = input - 50;
- i50 = (input / 50);
- }
- //calculate 20ps
- int i20 = input / 20;
- int a20 = 0;
- while (i20 >= 1) {
- a20++;
- input = input - 20;
- i20 = (input / 20);
- }
- //ccalculate 10ps
- int i10 = input / 10;
- int a10 = 0;
- while (i10 >= 1) {
- a10++;
- input = input - 10;
- i10 = (input / 10);
- }
- //calculate 5ps
- //int input = 20;
- int i5 = input / 5; //(=4)
- int a5 = 0;
- while (i5 >= 1) {
- a5++; //n5 = 0 is now n5 = 1
- input = input - 5; //20 - 5 -> input = 15 (5p taken away)
- i5 = (input / 5); //i5 = 15 / 5 -> i5 = 3
- }
- //calculate 2ps
- int i2 = input / 2;
- int a2 = 0;
- while (i2 >= 1) {
- a2++;
- input = input - 2;
- i2 = (input / 2);
- }
- //calculate 1ps
- int i1 = input / 1;
- int a1 = 0;
- while (i1 >= 1) {
- a1++;
- input = input - 1;
- i1 = (input / 1);
- }
- int sum = a200 + a100 + a50 + a20 + a10 + a5 + a2 + a1;
- //output
- System.out.print(amount + "p ");
- if (sum == 1) {
- System.out.print(sum + " coin");
- } else {
- System.out.print(sum + " coins");
- }
- // 200p
- if (a200 == 0) {
- System.out.print(" ");
- }
- if (a200 == 1) {
- System.out.print(" 200p ");
- }
- if (a200 > 1) {
- System.out.printf(" %d*200p ", a200);
- }
- // 100p
- if (a100 == 0) {
- System.out.print(" ");
- }
- if (a100 == 1) {
- System.out.print(" 100p ");
- }
- if (a100 > 1) {
- System.out.printf(" %d*100p ", a100);
- }
- // 50p
- if (a50 == 0) {
- System.out.print(" ");
- }
- if (a50 == 1) {
- System.out.print(" 50p ");
- }
- if (a50 > 1) {
- System.out.printf(" %d*50p ", a50);
- }
- // 20p
- if (a20 == 0) {
- System.out.print(" ");
- }
- if (a20 == 1) {
- System.out.print(" 20p ");
- }
- if (a20 > 1) {
- System.out.printf(" %d*20p ", a20);
- }
- // 10p
- if (a10 == 0) {
- System.out.print(" ");
- }
- if (a10 == 1) {
- System.out.print(" 10p ");
- }
- if (a10 > 1) {
- System.out.printf(" %d*10p ", a10);
- }
- // 5p
- if (a5 == 0) {
- System.out.print(" ");
- }
- if (a5 == 1) {
- System.out.print(" 5p ");
- }
- if (a5 > 1) {
- System.out.printf(" %d*5p ", a5);
- }
- // 2p
- if (a2 == 0) {
- System.out.print(" ");
- }
- if (a2 == 1) {
- System.out.print(" 2p ");
- }
- if (a2 > 1) {
- System.out.printf(" %d*2p ", a2);
- }
- // 1p
- if (a1 == 0) {
- System.out.print(" ");
- }
- if (a1 == 1) {
- System.out.print(" 1p ");
- }
- if (a1 > 1) {
- System.out.printf(" %d*1p ", a1);
- }
- } else {
- System.out.println("Invalid amount " + amount + "p");
- }
- input = BIO.getInt();
- }
- }
- }
- class Main extends BIO {
- public static void main(String args[]) {
- System.out.println("#Enter a line of text: ");
- String text = BIO.getString();
- int spaces;
- while (! text.equals("END")) {
- char[] textchars = text.toCharArray();
- int count = 0;
- for (int i=0; i<textchars.length; i++) {
- if (textchars[i] == ' ') {
- count++;
- }
- }
- //System.out.println("["+count+"]");
- //System.out.printf("[%d] %s %s", count, " spaces in ", \"",text,"\");
- System.out.println("["+count+"]" + " spaces in " + "\"" + text + "\"");
- text = BIO.getString();
- }
- }
- }
- class Main extends BIO {
- public static void main(String args[]) {
- System.out.println("#Enter any word: ");
- String text = BIO.getString();
- int vowels;
- while (! text.equals("END")) {
- char[] textchars = text.toCharArray();
- int count = 0;
- for (int i=0; i<textchars.length; i++) {
- if (textchars[i] == 'a' || textchars[i] == 'A' || textchars[i] == 'e' || textchars[i] == 'E' || textchars[i] == 'i' || textchars[i] == 'I' || textchars[i] == 'o' || textchars[i] == 'O' || textchars[i] == 'u' || textchars[i] == 'U') {
- count++;
- }
- }
- System.out.println("[" + count + "]" + " vowels in " + "\"" + text + "\"");
- text = BIO.getString();
- }
- }
- }
- class Main extends BIO {
- public static void main (String[] args) {
- System.out.println("#Enter 1 word: ");
- String word = BIO.getString();
- while (! word.equals("END")) {
- String wordlower = word.toLowerCase();
- int length = word.length();
- boolean ascend = true;
- int j=0;
- for (int i=0; i<length - 1; i++){
- j = i+1;
- if (wordlower.charAt(i) > wordlower.charAt(j)) {
- ascend = false;
- }
- }
- if (ascend){
- System.out.println(word + " letters in ascending order");
- }
- else {
- System.out.println(word + " letters not in ascending order");
- }
- System.out.println("#Enter another word: ");
- word = BIO.getString();
- }
- }
- }
- class Main extends BIO {
- public static void main (String[] args) {
- System.out.println("#Enter 1 word: ");
- String word = BIO.getString();
- while (! word.equals("END")) {
- String wordlower = word.toLowerCase();
- int length = word.length();
- int half = length / 2;
- boolean palindrome = true;
- for (int i=0, j=length -1; i<length/2; i++, j--){
- if (wordlower.charAt(i) != wordlower.charAt(j)) {
- palindrome = false;
- }
- }
- if (palindrome){
- System.out.println(word + " is a palindrome");
- }
- else {
- System.out.println(word + " is not a palindrome");
- }
- System.out.println("#Enter another word: ");
- word = BIO.getString();
- }
- }
- }
- class Main extends BIO {
- public static void main(String args[]) {
- System.out.print("#Enter line(s) of text: ");
- String s1=BIO.getString();
- StringBuffer buffer=new StringBuffer();
- int length=s1.length();
- System.out.print("#Enter max line length: ");
- int thrshld=BIO.getInt(); //this valueis threshold , which you can use
- int a=length/thrshld;
- if (a<=1) {
- System.out.println(s1);
- }else{
- String split[]=s1.split(" ");
- for (int j = 0; j < split.length; j++) {
- buffer.append(split[j]+" ");
- if (buffer.length()>=thrshld) {
- int lastindex=buffer.lastIndexOf(" ");
- if (lastindex<buffer.length()) {
- buffer.subSequence(lastindex, buffer.length()-1);
- System.out.println(buffer.toString().replace(' ', '.'));
- buffer=null;
- buffer=new StringBuffer();
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement