Results 1 to 4 of 4
- 02-26-2012, 02:00 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 1
- Rep Power
- 0
Help for finding out of error in this code
Hello I'm studying about CS and I wrote these codes for my Algorithm Homework We haven't used JAVA before so I wrote these codes in C# first but I couldn't convert them to JAVA's syntax.Could you help me for converting ?
import java.io.InputStream;
import java.util.Scanner;
import javax.print.DocFlavor.STRING;
import javax.swing.Spring;
import java.util.ArrayList;
class Book
{
public string name;
public string author;
public string publisher;
public int publishyear;
public string silinecek;
public void Info()
{
ArrayList karmaList = new ArrayList();
karmaList.Add(name);
karmaList.Add(author);
karmaList.Add(publisher);
karmaList.Add(publishyear);
if (silinecek == name)
{
karmaList.Clear();
}
Console.WriteLine("Kitaplarımızın Listesi");
foreach (object eleman in karmaList)
System.out.println("Kitap Bilgileri {0}", eleman);
}
public void Tanit(string alias, string developer, string company, int year,string kit)
{
name = alias;
author = developer;
publisher = company;
publishyear = year;
silinecek = kit;
}
static void Main(string[] args)
{
Scanner scn=new Scanner(System.in);
Book alpha = new Book();
int option;
do
{
System.out.println("------------ MENU -----------");
System.out.println("1 - Kitap Ekle");
System.out.println("2 - Kitabı sil");
System.out.println("3 - Tüm kitapları göster");
System.out.println("4 - Kapat");
System.out.println("-----------------------------");
System.out.println("Seçiminiz?");
option = NextInt(System.in);
string kito = " ";
switch (option)
{
case 1:
System.out.println("Lütfen girmek istediğiniz kitap sayısını giriniz");
int length =NextInt(System.in);
for (int i = 0; i < length; i++)
{
System.out.println("Lütfen kitabın adını giriniz");
string bookname=scn.nextLine(System.in);
System.out.println("Lütfen yazarın adını giriniz");
string typer =scn.nextLine(System.in);
System.out.println("Lütfen yayınevinin adını giriniz");
string ltd=scn.nextLine(System.in);
System.out.println("Lütfen basım tarihini giriniz");
int date=scn.NextInt(System.in);
string kit = kito;
alpha.Tanit(bookname, typer, ltd, date, kit);
}
break;
case 2:
System.out.println("Lütfen silinmesini istediğiniz kitabı giriniz");
kito = scn.nextLine(System.in);
break;
case 3:
alpha.Info();
break;
}
} while (option != 4);
}
}
- 02-27-2012, 11:26 AM #2
Re: Help for finding out of error in this code
Nothing specifically related to Eclipse. Moving to New to Java.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 02-27-2012, 11:30 AM #3
Re: Help for finding out of error in this code
1. Java is case sensitive. If those method calls are supposed to be to methods in standard JDK classes, many of them are wrong simply on account of being spelled with an uppercase letter.
2. When seeking help with compile time or run time errors, post the entire error message including any stack trace.
3. Scout around the FAQs or elsewhere on this site and learn to post your code within tags to retain its formatting. Get rid of the extraneous double spacing as nobody will bother to scroll up and down to read your few lines of code.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 02-27-2012, 06:48 PM #4
Member
- Join Date
- Oct 2011
- Posts
- 83
- Rep Power
- 0
Re: Help for finding out of error in this code
One thing I notice right away is that the syntax for foreach loops is different in Java than in C#
In C#:
foreach(Type element in collection)
In Java:
for(Type element:collection)
And yeah, it'd be easier to help you if you followed DarrylBurke's suggestions.
Similar Threads
-
error in this code
By gradiente99 in forum EclipseReplies: 11Last Post: 07-20-2010, 05:58 PM -
Need help finding error in code
By BobTedmen in forum New To JavaReplies: 3Last Post: 05-04-2010, 04:51 AM -
Help Finding Compiler error solution please
By jamesr2b in forum New To JavaReplies: 5Last Post: 04-30-2009, 06:07 AM -
help me in finding the entry points in the source code of java.....
By aks.nitw in forum Advanced JavaReplies: 0Last Post: 11-25-2008, 09:24 AM -
error in code
By dirtycash in forum New To JavaReplies: 2Last Post: 12-06-2007, 11:40 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks