Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.lang.String;
- public class shitsngiggles {
- public static void main(String[] args) {
- Scanner input=new Scanner(System.in);
- //#1
- int first, second, bet;
- System.out.println("Please enter first number (minimun):" );
- first=input.nextInt();
- System.out.println("Please enter second number (maximum): ");
- second=input.nextInt();
- do
- {
- System.out.println("Please enter a number between "+first+" and "+second);
- bet=input.nextInt();
- }while(bet<=first || bet>=second);
- //#2
- int even;
- System.out.println("Evens: ");
- for(even=1; even<=20; even++)
- {
- if(even%2==0)
- System.out.println(even);
- }
- //#3
- int num, s, sum=0;
- System.out.println("Please enter a number: ");
- num=input.nextInt();
- System.out.println("NumbersSum: ");
- for(s=1; s<=num; s++)
- {
- System.out.println(+s);
- sum+=s;
- }
- System.out.println("The sum is: "+sum);
- //#4
- double scores, sumScores=0;
- int numScores = 0;
- System.out.println("Please enter your score(s) (0 to quit): ");
- scores=input.nextDouble();
- while(scores!=0)
- {
- numScores+=1;
- sumScores+=scores;
- System.out.println("Please enter your score(s) (0 to quit): ");
- scores=input.nextDouble();
- }
- System.out.println("Your average is: "+sumScores/(double)numScores);
- //#5
- int num2, f, mult=1;
- System.out.println("Please enter a number: ");
- num2=input.nextInt();
- for(f=num2; f>=1; f--)
- {
- mult*=f;
- }
- System.out.println(num2+"!="+mult);
- //#6
- int num1, sum1=0, s1;
- System.out.println("Please enter a number: ");
- num1=input.nextInt();
- for(s1=1; s1<=num1; s1+=2)
- {
- sum1+=s1;
- }
- System.out.println(sum1);
- //#7
- String user, pass;
- int passLength;
- System.out.println("Enter a username: ");
- user=input.next();
- do{
- System.out.println("Enter a password that is at least 8 characters: ");
- pass=input.next();
- passLength=pass.length();
- user=user.toLowerCase();
- pass=pass.toLowerCase();
- }while(passLength<8);
- if(passLength>=8)
- System.out.println("Your username is "+user+" and your password is "+pass);
- //#8
- String name, mr="mr.", mrs="mrs.", ms="ms.", miss="miss";
- System.out.print("Please enter your name: ");
- name=input.next();
- if(name.compareToIgnoreCase(mr)==0)
- {
- System.out.println("Hello, sir!");
- }
- else if(name.compareToIgnoreCase(mrs)==0 || name.compareToIgnoreCase(ms)==0 || name.compareToIgnoreCase(miss)==0)
- {
- System.out.println("Hello, ma'am!");
- }
- else
- {
- System.out.println("Hello, "+name+"!");
- }
- //#9
- }
- }
Add Comment
Please, Sign In to add comment