Incompatible Types - Void Cannot Be Converted To String

Jul 26, 2014

I have coded three classes ,1 class containing the Main method. I have declared three private data fields in Staff class and two data fields in Address class. The problem is that I am assigning String type data field from the Staff and Address Class through the public set methods to String type array in a public void method in the Main class.

public static void main(String[] args){
// TODO code application logic here
System.out.println("-------------------------------------------------");
System.out.println("Press 1 - 6 To Perform Any One Following Action ");
System.out.println("1. Insert New Contact ");
System.out.println("2. Delete Contact By Name ");
System.out.println("3. Replace Info From Contact ");
System.out.println("4. Search Contact By Name ");
System.out.println("5. Show All Contacts ");
System.out.println("6. Exit Program ");

[Code] ....

View Replies


ADVERTISEMENT

Incompatible Types / Void Cannot Be Converted To Int

Jul 29, 2014

package input;

import javax.swing.JOptionPane;
public class Input {
public static void main(String[] args) {
int user;
user = JOptionPane.showMessageDialog(null, "Enter Your Age""); ERROR IS HERE
if(user <= 18) {
JOptionPane.showMessageDialog(null, "User is legit");
} else {
JOptionPane.showMessageDialog(null, "User is not legit");
}
}
}

I'm getting this error message :

incompatible types: void cannot be converted to int

unclosed string literal

View Replies View Related

Incompatible Types - String Cannot Be Converted To Double

Nov 23, 2014

import java.lang.Math;
import static java.lang.Math.random;
import java.util.Scanner;
public class LineofCoordinates
{
public static void main( String[] args, String x, String random, String exit, String y, String y2, String x2)

[Code] ....

View Replies View Related

Incompatible Types Error - String Cannot Be Converted To List

Jan 24, 2015

I am using netbeans and have an error that reads "incompatible types: String cannot be converted to List<String>"

List<List<String>> fileDArr;
fileDArr = new ArrayList<>();
Scanner tempStringScanner;
try {
for (int i = 0; i < FileDirectory.length; i++) {

[code] .....

I don't understand why I am receiving the error. I thought that .next() returned a String?

View Replies View Related

Incompatible Types - Int Cannot Be Converted To Boolean

Mar 12, 2015

int a, b, sum;
System.out.print("the sum is");
Scanner in = new Scanner(System.in);
a = in.nextInt();
b = in.nextInt();
Sum = a + b;
System.out.println("the sum us" + sum);

in "sum = a+b" its says "incompatible types: int cannot be converted to boolean" I dont understand why

View Replies View Related

Incompatible Types For Fname

May 6, 2014

import java.util.Scanner;
class potatoes {
public static void main(String[] args){
Scanner user = new Scanner(System.in);
String fname;
fname = user.nextLine;
String newfname = fname.substring(0, 3);
System.out.println(newfname);
}
}

This bit of code isnt working, it has something to do with incompatible types for fname

View Replies View Related

Incompatible Types Integer Boolean?

Mar 19, 2014

I am trying to write a program to calculate the monthly amount paid for a mortgage and the total amount but i keep getting this errors Attachment 5998

This is my program:

import static java.lang.Math.pow;
import java.io.*;
import java.util.*;
class MyInput
{ static private StringTokenizer stok;
static private BufferedReader br
= new BufferedReader(new InputStreamReader (System.in));
public static int readInt()

[code]....

View Replies View Related

Incompatible Types (Parsing Two-Dimensional Array)

Mar 4, 2015

What the program must do is to parse the string-declared two-dimensional array for the program to compute the student's scores in their quizzes, but I'm having difficulty in anything with Parsing so I don't know what will be the appropriate codes.

Error: incompatible types: String[][] cannot be converted to int[][]

import java.io.*;
public class Quiz3{
public static void main(String[]args)throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String [][]StudQuiz = new String [5][4];

[Code] ....

How am I able to compute the average of the score if the data that is needed to be computed is in the string-declared array?

View Replies View Related

Phone Number Class - Int Cannot Be Converted To String

Apr 5, 2014

import java.util.*;
public class PhoneNumber {
private int areacode;
private int number;
private int ext;
PhoneNumber() {

[Code] .....

I just can't seem to get it completely correct.

PhoneNumber.java:35: error: incompatible types: int cannot be converted to String
areacode = Integer.parseInt(str[0]);
^
PhoneNumber.java:38: error: cannot find symbol
for(i = 0; i < number.length; i++){
^
symbol: variable length

[Code] ......

View Replies View Related

Decimal Format Errors - String Cannot Be Converted To Double

Jun 19, 2014

I am working on a project that just calculates simple interest based upon a principal and a percent interest rate written as .xxxx from user.

I need the Loan amount and the final interest calculation to show up as a currency with commas in appropriate areas, the Rate to be expressed as X.xxx% instead of .xxxx

I keep getting this error when I compile:

C:JavaInterestCalculator.java:46: error: incompatible types: String cannot be converted to double
principal = formatter.format(principal);
^
C:JavaInterestCalculator.java:49: error: incompatible types: String cannot be converted to double
rate = formatter.format(rate);
^
C:JavaInterestCalculator.java:52: error: incompatible types: String cannot be converted to double
totalInterest = formatter.format(totalInterest);
^
3 errors

Tool completed with exit code 1

And here is my code

import java.util.Scanner;
import java.text.NumberFormat;
import java.text.DecimalFormat;
// class declaration
public class InterestCalculator
{
// main method declaration

[Code] .....

View Replies View Related

Using String In A Void Or INT?

Apr 20, 2014

I am trying to make a custom texture system for a block in Minecraft, I am not too advanced with Java and am not sure how to make this work the way I want it to.

Java Code:

/** The list of the types of step blocks. */
public static final String[] blockStepTypes = new String[] {"stone", "sand", "wood", "cobble", "brick", "smoothStoneBrick", "netherBrick", "quartz"};
private Icon missing;
private Icon icon1;
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/

[code]....

Alright, so basically I figured I could just tell the code to see if the block is made out of Stone, then to set the texture to Stone, or if it's made out of Sand, then set it to Sand.What I usually get is Eclipse telling me to "insert '!= null' check", "insert '!= null' check", and then just error out saying "Opperator != is undefined for the argument type(s) boolean null"

View Replies View Related

What Is Different Between Void Main And Public Void Main

Sep 15, 2014

what is different between void main() and public void main()

View Replies View Related

Doing Merge Sort - Incompatible Type

Apr 10, 2014

I am new in java.. I am having a problem when doing merge sort. This is my coding...

Java Code:

import java.util.*;
public class Person
{
public static void main(String[] args)
{
String[] list = {"

[Code] ....

the error is incompatible type at 'sorted = merge(left,right);'

View Replies View Related

Boolean Cannot Be Converted To Int

Jun 11, 2014

I do not see a boolean trying to be converted into an int. Could my decompiler have caused this?

this.redStones[this.tabIDHover == i].drawSprite(6 + paddingX + ((client.clientSize >= 1) ? 2 : 0) - ((this.longTabs && client.clientSize >= 1) ? 240 : 0) + x, 261 + paddingY + ((this.longTabs && client.clientSize >= 1) ? 37 : 0) - ((client.clientSize == 0) ? 261 : 0));
this.redStones[this.tabIDHover == i + 8].drawSprite(6 + paddingX + ((client.clientSize >= 1) ? 2 : 0) + x, 298 + paddingY);

View Replies View Related

Int Cannot Be Converted To Node

Nov 17, 2014

Is it possible to convert an int to a node[]?

Node[] expResult = new Node[2];
for(int i: expResult){
expResult[i] = i.;
}

View Replies View Related

Array Of Integers - Cannot Be Converted To Int

Dec 18, 2014

I have a method that receives an array of integers and saves the ID of the user inside the array of integers and I keep getting the error: "int[] cannot be converted to int".Here is the code:

public boolean Borrow (String TitleOrAuthor,int id){
int count = 0;
int b1 = 0;
int BookCount [] = new int [b1];
for (int i=0;i<Bcount;i++){
if(Booklist[i].getTitle().equals(TitleOrAuthor))
for(int j=0;j<b1;j++){
BookCount [j]= Booklist[i].getCopies();
BookCount [j]= id;
b1++;

[code]...

View Replies View Related

Gregorian Calendar Cannot Be Converted Into Double

Dec 7, 2014

I wrote this application but somehow in my CheckingAccount, I get an error saying GregorianCalander cannot be converted into double.

The line that gives me an error is "super(name, number, openDate, balance);"

package finalproject;
import java.util.*;
import java.text.SimpleDateFormat;
public class CheckingAccount extends Account {
final SimpleDateFormat sd = new SimpleDateFormat("yyy/mm/dd");
CheckingAccount(String name, String number, GregorianCalendar openDate, double balance) {
super(name, number, openDate, balance);

[Code] .....

View Replies View Related

How To Make Password Converted Into Asterisk

Oct 11, 2014

package exercises;
import java.util.*;
public class Log_in_form {
static Scanner scan=new Scanner(System.in);
public static void main(String[] args) {
String username="rosas";
String password="sandy";

[Code] .....

View Replies View Related

Converted Java File Into EXE - How To Install And Use It

Sep 22, 2014

I have created a java file and coverted it into exe file.. that exe file can be run directly by clicking the icon.... i dont need this, i want to install this java exe file and then use it.. is there any possible way?

View Replies View Related

Int Cannot Be Converted To Boolean On Password Checker Program

Apr 28, 2014

I am trying to write a password checker program and thats the error i get. (the final error!) but this one i dont know how to fix. here is my code.

/* Text
Text
text
*/

import java.util.Scanner; // Imports the Scanner class to get Keyboard Inputs
class PriceRichardChapter5Test
{
public static void main (String [] args) {
String Password; // Creates the Password variable

[Code] .....

View Replies View Related

Define Variable When User Has To Type Into Program So It Can Be Converted

Sep 23, 2014

I don't understand how i'm supposed to define a variable when the user has to type it into the program so it can be converted. This program i'm working on is supposed to convert from meters to feet (meter = feet * 0.305) but the user has to type in the meters they want converted. how do i solve the problem that keeps coming up that says "variable meter symbol cant be found" ? I keep trying different lines to no avail

public class Lab2
{
public static void main(String[] args) {
double feet = meter * 0.305;
double meter = feet/0.305;
System.out.println("Enter in feet for conversion to meters");
meter = meter * 0.305;

[Code] .....

View Replies View Related

When To And Not To Use Void

Apr 9, 2014

I know void means it doesn't return anything but to me when I think it doesn't return anything it just does equations and other things. So why can you use this? Or is Void like returning input such as a Scanner?

void printStates() {
System.out.println("cadence:" +
cadence + " speed:" +
speed + " gear:" + gear);
}

View Replies View Related

Working Through Printf And Void

Sep 1, 2014

I have a program that I have created from scratch called Product and I also created a Tester program to test my theory. The only problem that I have is that I am getting an error with this statement System.out.printf statement. The statement needs to print out "Program [name = HP ENVY x360 TouchSmart, price = $xxxxxx". The error states that "The method printf(String, Object...) in the PrintStream is not applicable for the arguments (String, String, void).

Which tells me that it is referencing back to the class file where I have

public void applyDiscount(double percent) {
percent = price - (price * percent); //establishing the discount
}

The lines of code in my tester file are (partly displayed)

String formatString = "Product[name = %s, price = %.2f]";
System.out.printf(formatString, product.getName(), product.getPrice())
//user input the discount amount
System.out.println("Enter discount percentage [0 - 100]: %.2f ");
double discount = user_input.nextDouble();
System.out.printf(formatString, product.getName(), product.applyDiscount(discount)); //This is the line giving me an error.
}

View Replies View Related

How To Assert A Void Method

Nov 5, 2014

how to assert a void method like shown in the photos,

View Replies View Related

Declaring Parameters - Use Void For

Mar 1, 2015

I want to have parameters that I use the "void" for, in other words it doesn't return anything.

class code
{
void go()
{
int TestStuff t = new TestStuff();
t.takeTwo(12,34)
}
void takeTwo (int x, int y) {
int z = x + y;
System.out.println("Total is:" + z);
}
}

View Replies View Related

Void And Static In Main Method?

Jan 7, 2014

What does void and static mean in the main method?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved