Java and Javascript help


#1

How would you write this in Java:
const name = prompt("…");
const rate = prompt("…");
alert(... ${name - (name * rate / 100) });


#2
import javax.swing.JOptionPane;

// one class needs to have a main() method
public class HelloWorld
{
  // arguments are passed using the text field below this editor
  public static void main(String[] args)
  {
     //since u multiplied variable name with rate,
      //I assume u mean it a number
      //double is used for decimal point numbers
      //because rate is usually decimal point
      //I used double for both
      double name=5;
      double rate= 2.5;
      double result = ((name * (rate / 100)) - name);
    
      //System.out.print(result);
      JOptionPane.showMessageDialog( null, "result is: " + result );
  }
}

#3

Thank you very much!


#4

please test it to see if you like it…
Here is more “JOptionPane” examples in the website below


#5

you are very welcome. Make sure to test it