Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package week2;
- import java.util.Scanner;
- public class Day11A {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String option;
- double interestYearly = 0, interestMonthly = 0;
- System.out.println("Choose Conversion");
- System.out.println("1 - yearly to monthly");
- System.out.println("2 - monthly to yearly");
- option = sc.nextLine();
- switch (option) {
- case "1":
- System.out.print("Enter yearly interest: ");
- interestYearly = sc.nextDouble();
- //dahil static yung mga method, di na need gawan ng object
- interestMonthly = yearToMonth(interestYearly);
- break;
- case "2":
- System.out.print("Enter monthly interest: ");
- interestMonthly = sc.nextDouble();
- interestYearly = monthToYear(interestMonthly);
- break;
- default:
- System.out.println("not part of options");
- }
- System.out.println("yearly interest: " + interestYearly);
- System.out.println("monthly interest: " + interestMonthly);
- }
- public static double yearToMonth(double interestYearly){
- double interestMonthly = 100 * (Math.pow(((1+interestYearly)/100), (1/12)) - 1);
- return interestMonthly;
- }
- public static double monthToYear(double interestMonthly){
- double interestYearly = 0;
- return interestYearly;
- }
- }
- //-----------------------------------------
- package week2;
- import java.time.LocalDate;
- import java.time.LocalDateTime;
- import java.time.LocalTime;
- import java.util.Locale;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- public class Day11B {
- public static void main(String[] args) {
- LocalDateTime dateTimeNow = LocalDateTime.now();
- System.out.println(dateTimeNow);
- LocalDate dateNow = dateTimeNow.toLocalDate();
- System.out.println(dateNow);
- LocalTime timeNow = dateTimeNow.toLocalTime();
- System.out.println(timeNow);
- LocalDate dateOnly = LocalDate.parse("2023-09-15");
- //pag parse iisang klase lang ng date na style ang tanggap nya
- System.out.println(dateOnly);
- System.out.println(dateOnly.getDayOfWeek());
- SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy", Locale.ENGLISH);
- String dateString = "10/19/2023";
- try {
- Date dateOnly2 = sdf.parse(dateString);
- System.out.println(dateOnly2);
- } catch (ParseException e) {
- }
- System.out.println("from " + dateNow + " to " + dateOnly);
- System.out.println(dateNow.compareTo(dateOnly));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment