Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A magic day is a day in which the product of the numerical value of the month an

ID: 3734776 • Letter: A

Question

A magic day is a day in which the product of the numerical value of the month and day equals the last two digits of the year. Thus April 4, 2016, is a magic date because 4 X 4 = 16. (April is the 4th month of the year.) Write a program which takes in the date, month, and year and determines if they form a magic day. 3) Gizmos are priced according to the table: quantity price 1 to 10 $50 each 11 to 50 $40 each 51 to 100 $35 each over 100 $30 each Write a program which takes in the quantity of gizmos ordered and prints out the cost of the order according to this table in java netbeans.

Explanation / Answer

MagicDayOrNot.java

import java.util.Scanner;

public class MagicDayOrNot {

public static void main(String[] args) {

//Declaring variables

int month,year,day,i=0,n=2,val=0;

/*

* Creating an Scanner class object which is used to get the inputs

* entered by the user

*/

Scanner sc = new Scanner(System.in);

//Getting the input entered by the user

System.out.print("Enter Month (Between 1-12):");

month=sc.nextInt();

System.out.print("Enter day (Between 1-31):");

day=sc.nextInt();

System.out.print("Enter Year:");

year=sc.nextInt();

  

//Getting the last two digits of the year

while(i<n)

{

val+=year%10*Math.pow(10,i);

year=year/10;

i++;

}

  

//Checking the day is magic day or not

if(month*day==val)

System.out.println("The Day is a Magic Day");

else

System.out.println("The Day is not a Magic Day");

}

}

__________________

Output:

Enter Month (Between 1-12):4
Enter day (Between 1-31):4
Enter Year:2016

The Day is a Magic Day

_______________

GizmosPrice.java

import java.util.Scanner;

public class GizmosPrice {

public static void main(String[] args) {

//Declaring variables

int qty;

double cost,eachPrice=0;

/*

* Creating an Scanner class object which is used to get the inputs

* entered by the user

*/

Scanner sc = new Scanner(System.in);

//Getting the input entered by the user

System.out.print("Enter Quantity of gizmos ordered :");

qty=sc.nextInt();

  

if(qty>=1 && qty<=10)

{

eachPrice=50;

}

else if(qty>=11 && qty<=50)

{

eachPrice=40;

}

else if(qty>=51 && qty<=100)

{

eachPrice=35;

}

else if(qty>100)

{

eachPrice=30;

}

//Displaying the output

System.out.println("Cost of Order :$"+qty*eachPrice);

}

}

___________________

Output:

Enter Quantity of gizmos ordered :70
Cost of Order :$2450.0

_______________Thank You

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote