Please write program in JAVA ONLY thank you There are 2 par
Please write program in JAVA ONLY , thank you! There are 2 parts to this question
#1 - Write a program that prompts the user to input an integer between 0 and 35. If the number is less than or equal to 9, the program should output the number; otherwise, it should output A for 10, B for 11, C for 12, ....and Z for 35. (Hint: use the cast operator, (char)(), for numbers >=10 OR use a switch statement for all those cases >=10).
#2 - A box of cookies can hold 24 cookies and a container can hold 75 boxes of cookies. Write a program that prompts the user to enter the total number of cookies, then outputs the number of boxes and the number of containers to ship the cookies. If there are not enough cookies to fill a box, the box can be discarded and the number of leftover cookies should be output. If the number of boxes will not fill a container, then the leftover boxes can be discarded and the number of leftover boxes should be output.
For example: You need 1800 cookies (75 boxes each filled with 24 cookies) to fill a container. The user enters 2500 cookies - example output might be:
You entered 2500 cookies.
1 container with 75 boxes of 24 cookies shipped
29 boxes of 24 cookies discarded
4 cookies discarded
Solution
// IntToChar.java
 import java.util.Scanner;
 public class IntToChar
 {
 public static void main(String[] args)
 {
      Scanner sc=new Scanner(System.in);
      int number;
 
      while(true)
      {
         System.out.println(\"\ Enter an integer between 0 and 35(-1 to end): \");
         number = sc.nextInt();
        if(number == -1 )
           break;
        if(number >= 10)
         {
             char b = (char)(number + 55);
             System.out.println(\"output: \" + b);
         }
        else
           System.out.println(\"output: \" + number);
      }
 }
 }
/*
 output:
Enter an integer between 0 and 35(-1 to end):
 10
 output: A
Enter an integer between 0 and 35(-1 to end):
 15
 output: F
Enter an integer between 0 and 35(-1 to end):
 20
 output: K
Enter an integer between 0 and 35(-1 to end):
 34
 output: Y
Enter an integer between 0 and 35(-1 to end):
 -1
 */
// Cookies.java
 import java.util.Scanner;
 public class Cookies
 {
 public static void main(String[] args)
 {
     Scanner sc=new Scanner(System.in);
      int cookies, boxes,discardedCookies, containers, discardedBoxes;
     System.out.println(\"Enter the total number of cookies:\");
      cookies = sc.nextInt();
      System.out.println(\"\ You entered \"+ cookies + \" cookies\");
     boxes = cookies / 24;
      discardedCookies = cookies % 24;
      containers = boxes / 75;
      discardedBoxes = boxes % 75;
      boxes = boxes - discardedBoxes;
     if (containers > 0)
        System.out.print(containers + \" container, \");
      if (boxes > 0)
        System.out.print(boxes + \" boxes needed \ \");
      if (discardedBoxes > 0)
        System.out.println(\"discarded boxes: \"+ discardedBoxes);
      if (discardedCookies > 0)
        System.out.println(\"discarded cookies: \" + discardedCookies);
 }
 }
/*
 output:
Enter the total number of cookies:
 2500
You entered 2500 cookies
 1 container, 75 boxes needed
 discarded boxes: 29
 discarded cookies: 4
*/


