In: Computer Science
Please find below code and Don't forget to give a Like.
Refer screenshot for output.
a)
import java.lang.Math;
public class Main
{
public static void main(String[] args) {
String
[]arr={"jan","feb","march","april","may","june","july","august","september","october","november","december"};
int min=1,max=12;
int a =(int)(Math.random()*(max-min+1)+min);
for(int i=1;i<=arr.length;i++){
if(i==a){
System.out.print(a+" "+arr[i-1]);
}
}
}
}
b)
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
double conversion=0.0;
Scanner input=new Scanner(System.in);
System.out.print("Enter the exchange rate from dollars
to SR:");
double price=input.nextDouble();
System.out.print("Enter 0 to convert dollars to SR and
1 vice versa:");
int choice=input.nextInt();
if(choice==0){
System.out.print("Enter dollar amount:");
double d_amount=input.nextDouble();
conversion=price*d_amount;
System.out.print("$"+d_amount+" is "+conversion+"
SR");
}
if(choice==1){
System.out.print("Enter SR amount:");
double s_amount=input.nextDouble();
price=1/price;
conversion=price*s_amount;
System.out.print(s_amount+" SR "+" is
$"+conversion);
}
}
}