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

PLEASE HELP! **I have asked this question 3 times and have yet to get a corrrect

ID: 669212 • Letter: P

Question

PLEASE HELP!

**I have asked this question 3 times and have yet to get a corrrect response, so please be sure to include a sample output thank you.**

calculate simple Interest based on the principle amount and time entered by the user. However the rate of interest depends on Random number in the program which ranges from 1 to 5.If the random number is less than 3 interest rate is 5 ,if it is between 3 and 5 interest rate is 10 and if it equal to and more than 5 interest rate is 15.

Follow the steps mentioned below to know about Random class and random number

The program also required to take string input from the user and say if it is even length or odd length

Explanation / Answer

NewClass. java

import java.util.*;
public class NewClass {
public static void main (String[] args){
double principal,time;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the amount: ");
principal=sc.nextDouble();
System.out.println("Enter the time: ");
time=sc.nextDouble();
String str;
System.out.println("Enter the String: ");
str=sc.next();
double si;
int intrestRate = 0,len;
Random rand=new Random();
int num=rand.nextInt(6);//genrate a random number between 1 to 6
if(num<3){
intrestRate=5;
}else if(num>=3&&num<5){
intrestRate=10;
}else if(num>=5){
intrestRate=15;
}
si=(principal * time * intrestRate)/100;//caluculating simple intrest
len=str.length();
System.out.println("The intrest rate is "+intrestRate+" and simple intrest is "+si);
if(len%2!=0){
System.out.println("You have entered odd length string");
} else {
System.out.println("You have entered even length string");
}
}
  
}

Expected output :

Enter the amount:
1500
Enter the time:
5
Enter the String:
jos
The intrest rate is 5 and simple intrest is 375.0
You have entered odd length string

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