1 Replies - 346 Views - Last Post: 16 August 2012 - 05:35 AM Rate Topic: -----

#1 mariie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-August 12

I can't figure out why it won't compile.

Posted 16 August 2012 - 05:27 AM

/**
* @(#)mimics.java
*
* mimics application
*
* @author
* @version 1.00 2012/8/16
*/

import java.util.*;
public class mimics {

public static void main(String[] args) {

int first=0;
int second=0;
char ope;
String rate=ope;


Scanner user=new Scanner(System.in);
System.out.println("input first and second number: " + first);
first=user.nextInt();
System.out.println("input first and second number: " + second);
second=user.nextInt();

System.out.println("input operator: " + rate);
rate=user.next();
ope=rate.charAt(0);







switch (ope) {

case 1:
System.out.println("Enter the number one=" + (first+second));
break;
case 2:
System.out.println("Enter the number two=" + (first-second));
break;
case 3:
System.out.println("Enetr the number three="+ (first*second));
break;
case 4:
System.out.println("Enter the number four="+ (first/second));
break;
default:
System.out.println("Invalid Entry!");


}

}
}

ERROR MESSAGE :

incompatible types

Is This A Good Question/Topic? 0
  • +

Replies To: I can't figure out why it won't compile.

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2110
  • View blog
  • Posts: 8,774
  • Joined: 20-September 08

Re: I can't figure out why it won't compile.

Posted 16 August 2012 - 05:35 AM

Quote

String rate = ope;



Makes no sense. Different types. Delete that line
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1