Please answer 6 I am using codelite Thanks Write a program

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.

Solution

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

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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site