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 ");
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
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
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?
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
I'm getting an error on line 51 and don't know what it means?
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package million; import java.util.Scanner; import java.util.ArrayList;
I am reading a file and sorting a list, and I cannot figure out why I am getting an error on line 15 that contains the following code
Collections.sort(sortedContributorList, new Contributor());
This is the error I keep getting:
The method sort(List<T>, Comparator<? super T>) in the type Collections is not applicable for the arguments (LinkedList<Contributor>, Contributor)
import java.util.*; import java.io.*; public class myhashTable { public static LinkedList<Contributor> sortedContributorList = new LinkedList<Contributor>(); public myhashTable(){
package progProject5; // Implementation of single linked list. public class SingleLinkedList<E> { private Node<E> head = null; private int size = 0; // Methods
[Code] ......
I am in learning process and I know its very basic question but I got stucked at addAfter() where I need to insert the node after the given node.
I am currently making a double linked list class in my compsci class. i was absent for a few days and i need to make an add method for the class. when i go to compile test code i made i get a null pointer error on line 36. This is the node class i wrote and the double linked list class i wrote.
node class
public class Node{ // Two references and Data Node prev; Node next; String data; public Node(){ prev = null; next = null;
[Code] ....
This is the class i need working with ( in the doublelinkedlist class)
Im running into some problems with the Java compiler. This is my code:
public class DoublyLinkedList<T> implements SimpleList<T> { protected Node dummy; protected int n; public DoublyLinkedList(){
dummy = new Node(); dummy.next = dummy; dummy.pre = dummy;
n = 0;
[Code] ....
I want to use a dummy node in my implementation of the Doubly Linked List, so it will be easier to code all the methods I need to write. I keep on getting a problem with line 14 and 15:
dummy.next = dummy;
dummy.pre = dummy;
// cannot find symbol variable next (compiler error)
Im making a simple code to add an array to a List (the code im referring to is <String> )
import java.util.*; public class L5_ArrayListProgram { public static void main(String[] args){ String[] things = {"lasers","ghouls", "food", "dark"}; List<String>list1 = new ArrayList<String>(); for(String x: things) list1.add(x);
My simple question is - what are the <String> ...<String> for? I understand it makes the list1 variable a string, but why is it made like this? do we usualy use <String> when we need to make a variable a String?
Suppose that you have an ArrayList and that it contains String objects. Which declaration of the ArrayList requires that objects retrieved using the get method be cast to Strings before calling a String method?
I. ArrayList a = new ArrayList(); II. ArrayList<Object> a = new ArrayList<Object>; III. ArrayList<String> a = new ArrayList<String>;
A. I only B. II only C. III only D. I and II only E. I, II, and III
I know that all of these are ways to declare an Array List, but I am unfamiliar with the last two since I usually just declare my Array Lists with the first option.
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++;
We were suppose to make a program for an assignment and the prof provided some codes to start of. What does this basically mean? How do i access the string arrays from consolelist?
class ConsoleInfo { private String conTitle; private double conPrice; private int conQty; private String conPic; private static String empPassword; ConsoleInfo(String title, double price, int qty,String pic)
I am looking for a good and reliable library to read a string to construct a list of Integers, Doubles, Booleans, etc. This library should be robust enough to handle faulty input from an inexperienced user.