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

Please answer #6 , I am using codelite . Thanks Write a program that prompts the

ID: 3792216 • Letter: P

Question

Please answer #6 , I am using codelite . Thanks

Write a program that prompts the user to enter a positive integer. The program then prints the digits in reverse order. For example, your program should produce the following output Enter an integer: 1234 Digits reversed: 4321 assuming the user enters 1234 when prompted. The integer can have any number of digits. Your program should make use of the modulo operator. The modulo operator (%) returns the remainder of the division of two integers. For example, int a = 5, b = 3, c; c = a % b; printf("%d ", c); prints the value 2, because 5 divided by 3 is 1 with remainder 2. As a Write a program that implements a simple calculator. The user is prompted for an expression. They enter a number, a character (one of + - */) and another number. The program then prints the value of the expression. For example. Expression: 2.5 * 3.7 Equals: 9.250000 Your program should use the switch structure.

Explanation / Answer

Program:

Please add space in between each entry

import java.util.Scanner;

public class Calculator {

   public static void main(String[] args) {
       Scanner s =new Scanner(System.in);
       //Please add space in between each entry
       System.out.print("Expression :");
       float no1=s.nextFloat();
       String op=s.next();
       float no2 =s.nextFloat();
       switch(op)
       {
       case "+":
           System.out.println("Equals: "+(no1+no2));
           break;
       case "-":
           System.out.println("Equals: "+(no1-no2));
           break;
       case "*":
           System.out.println("Equals: "+(no1*no2));
           break;
       case "/":
           System.out.println("Equals: "+(no1/no2));
           break;
       }  
   }
}

Output:

Expression :2.5 * 3.7
Equals: 9.25

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