Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Question5
- package lab_03_Assignment_Work;
- import java.util.Scanner;
- public class Ques5 {
- public static void main(String[] args) {
- int date;
- int month;
- int year;
- int r = 0;
- int m = 0;
- int y = 0;
- String s = "" ;
- Scanner k = new Scanner(System.in);
- System.out.print("date: ");
- date = k.nextInt();
- System.out.print("month: ");
- month = k.nextInt();
- System.out.print("year: ");
- year = k.nextInt();
- if(month == 1){m = 0;
- s = "January ";
- }
- else if(month == 2){m = 3;
- s = "February ";
- }
- else if(month == 3){m = 3;
- s = "March ";
- }
- else if(month == 4){m = 6;
- s = "April ";
- }
- else if(month == 5){m = 1;
- s = "May ";
- }
- else if(month == 6){m = 4;
- s = "June ";
- }
- else if(month == 7){m = 6;
- s = "July ";
- }
- else if(month == 8){m = 2;
- s = "August ";
- }
- else if(month == 9){m = 5;
- s = "September ";
- }
- else if(month == 10){m = 0;
- s = "October ";
- }
- else if(month == 11){m = 3;
- s = "November ";
- }
- else if(month == 12){m = 5;
- s = "December ";
- }
- if (1600 <= year && year >= 1699){y=6;}
- else if(1700 <= year && year >= 1799){y=4;}
- else if(1800 <= year && year >= 1899){y=2;}
- else if(1900 <= year && year >= 1999){y=0;}
- else if (2000 <= year && year >= 2099){y=6;}
- int re = year%100;
- r = re + (int)((re)/4) + date + m +y ;
- if (r>=7){
- r = r%7;
- }
- if (year%100 == 0){
- if (year%400 == 0 && (month == 1 || month == 2)){
- r = r - 1;
- }
- }
- else{
- if (year%4 == 0 && (month == 1 || m == 2)){
- r = r - 1;
- }
- }
- switch (r){
- case 1:
- System.out.println(date+"th "+ s + year + " was a Monday!");
- break;
- case 2:
- System.out.println(date+"th "+ s + year + " was a Tuesday!");
- break;
- case 3:
- System.out.println(date+"th "+ s + year + " was a Wednesday!");
- break;
- case 4:
- System.out.println(date+"th "+ s + year + " was a Thursday!");
- break;
- case 5:
- System.out.println(date+"th "+ s + year + " was a Friday!");
- break;
- case 6:
- System.out.println(date+"th "+ s + year + " was a Saturday!");
- break;
- case 0:
- System.out.println(date+"th "+ s + year + " was a Sunday!");
- break;
- }
- }
- }
- Question1
- package lab_03_Assignment_Work;
- import java.util.Scanner;
- public class Ques1 {
- public static void main(String[] args) {
- double s = 0.0;
- int n;
- Scanner scan = new Scanner(System.in);
- n = scan.nextInt();
- for (int i = 1; i <= n ; i++) {
- s = s + (1.0/i);
- }
- System.out.println( s );
- }
- }
- Question2
- package lab_03_Assignment_Work;
- import java.util.Scanner;
- public class Ques2 {
- public static void main(String[] args) {
- double no;
- double paise = 0.0;
- int rupee;
- Scanner k = new Scanner(System.in);
- no = k.nextDouble();
- rupee = (int)no;
- paise = 100*(no - rupee);
- System.out.println(rupee+" Rupees and "+(int)paise+" Paise");
- }
- }
- Question3
- package lab_03_Assignment_Work;
- import java.util.Scanner;
- public class Ques3 {
- public static void main(String[] args) {
- double fahrenheit;
- double celcius;
- Scanner k = new Scanner(System.in);
- fahrenheit = k.nextDouble();
- celcius = (fahrenheit-32)/1.8;
- System.out.printf("%5.6f%n",celcius);
- }
- }
- pattern printing nhi ki h maine
Add Comment
Please, Sign In to add comment