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

1. Develop a program that receives as input 3 names of stars. 2. For each star e

ID: 3543917 • Letter: 1

Question

1. Develop a program that receives as input 3 names of stars.

2. For each star enter its distance and brightness

3. For each star calculate the amount of light that we see: formula is: amount of light = distance (in miles) * brightness (number between .2 and .8)

4. Assign a lumen value based on the follow: >=200000 = Very bright, >150000 = Bright, >75000 = Dull, >36000 = very dull, everything else = Invisible

5. Calculate the overall average lumens for all stars.

6. Print out each star's amount of light, its lumen value and the overall average for all stars

You should use memory, decision, looping and arrays to solve this. You may do this as inline code.


Explanation / Answer

import java.util.*;

import java.lang.*;

import java.io.*;


class driver

{

public static void main (String[] args)

{

Scanner scan = new Scanner(System.in);

String s[] = new String[3];int i = 1;double count = 0.0;

double d[] = new double[3];

double b[] = new double[3];

double l[] = new double[3];

String lv[] = new String[3];

while(i<=3)

{

System.out.println("Enter the name of star "+ i+" :");

s[i-1] = scan.nextLine();

System.out.println("Enter the Distance in miles : ");

d[i-1] = new Double(scan.nextLine());

System.out.println("Enter the Brightness,number b/w 2 and 8 : ");

b[i-1] = new Double(scan.nextLine());

l[i-1] = d[i-1]*b[i-1];

count = count + l[i-1];

if(l[i-1]>=200000)

lv[i-1] = "Very Bright";

else if(l[i-1]>150000)

lv[i-1] = "Bright";

else if(l[i-1]>75000)

lv[i-1] = "Dull";

else if(l[i-1]>36000)

lv[i-1] = "Very Dull";

else

lv[i-1] = "Invisible";

i++;

}

count = count/3;

i = 1;

while(i<=3)

{

System.out.println(s[i-1]+"'s Amount of light is "+l[i-1]);

System.out.println(s[i-1]+"'s Lumen Value is "+lv[i-1]);

i++;

}

System.out.println("Average amount of light is "+count);

}

}