java programmers

  suburban train 15:21 04 May 2003
Locked

is there any java programmers here to help me today?

  Geeky_Ali 15:46 04 May 2003

Yes, how can I help?

  suburban train 15:56 04 May 2003

The class that im working on is called PhoneCalc and im trying to create a local variable called ProductCode which needs to be a String.

but dont change the ConsoleInput at the bottom of the thread

then modify the loop so it displays full order details e.g

Product Code: Manufacturer Price


/** * Write a description of class PhoneCalc here. * * (Abol Akrami) * */public class PhoneCalc{ private double[] Prices = new double[ 5 ]; private String[] ProductCodes = new String[ 15 ]; private String[] Manufacturers = new String[ 15 ]; public PhoneCalc() {} public void AddPhonePricesWithLoop () { double Price; String ProductCode; String Manufacturer; for (int IndexNum = 0; IndexNum <5; IndexNum++) { System.out.println("Please enter price of phone"); Prices [ IndexNum ] = ConsoleInput.readDoubleValue(); } for (int IndexNum = 0; IndexNum < Prices.length; IndexNum++) { System.out.println ("Please enter the product code"); ProductCodes[ IndexNum ] = ConsoleInput.readStringObject(); } for (int IndexNum = 0; IndexNum < 5; IndexNum++) { System.out.println ("Please enter Manufacturer"); Manufacturers [ IndexNum ] = ConsoleInput.readStringObject(); for (int IndexNum = 0; IndexNum <Prices.length; IndexNum++) System.out.println ("Product Code:" + ProductCodes[ IndexNum ] + ",Price ý" + Prices[ IndexNum ] + "Manufacturers:" + Manufacturers[ IndexNum ]); } public static void main (String[] args) { PhoneCalc sys = new PhoneCalc (); sys.AddPhonePricesWithLoop (); }}





ConsoleInput

import java.io.*; /** * Write a description of class ConsoleInput here. * * @author (your name) * @version (a version number or a date) */public class ConsoleInput{ public static char readCharValue () { BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in)); char c = '\0'; try { c = Inputter.readLine ().charAt (0); } catch (IOException e) { System.err.println ("Invalid character entered"); } return c; } public static int readIntValue () { BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in)); int i = 0; try { i = Integer.parseInt (Inputter.readLine ()); } catch (IOException e) { System.err.println ("Invalid value entered"); } return i; } public static long readLongValue () { BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in)); long l = 0; try { l = Long.parseLong (Inputter.readLine ()); } catch (IOException e) { System.err.println ("Invalid value entered"); } return l; } public static float readFloatValue () { BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in)); float f = 0; try { f = Float.parseFloat (Inputter.readLine ()); } catch (IOException e) { System.err.println ("Invalid value entered"); } return f; } public static double readDoubleValue () { BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in)); double d = 0; try { d = Double.parseDouble (Inputter.readLine ()); } catch (IOException e) { System.err.println ("Invalid value entered"); } return d; } public static String readStringObject () { BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in)); String str = null; try { str = Inputter.readLine (); } catch (IOException e) { System.err.println ("Invalid text entered"); } return str; }}

  Geeky_Ali 16:04 04 May 2003

Okay I'll get back to you soon.

  suburban train 16:12 04 May 2003

ok thank you

  Geeky_Ali 16:35 04 May 2003

You just have a few brackets in the wrong place. Try this:

/** * Write a description of class PhoneCalc here. * * (Abol Akrami) * */
public class PhoneCalc{
private double[] Prices = new double[ 5 ];
private String[] ProductCodes = new String[ 15 ];
private String[] Manufacturers = new String[ 15 ];

public PhoneCalc() {}

public void AddPhonePricesWithLoop () {
double Price;
String ProductCode;
String Manufacturer;

for (int IndexNum = 0; IndexNum <5; IndexNum++) {
System.out.println("Please enter price of phone");
Prices [ IndexNum ] = ConsoleInput.readDoubleValue();
}

for (int IndexNum = 0; IndexNum < Prices.length; IndexNum++) {
System.out.println ("Please enter the product code");
ProductCodes[ IndexNum ] = ConsoleInput.readStringObject();
}

for (int IndexNum = 0; IndexNum < 5; IndexNum++) {
System.out.println ("Please enter Manufacturer");
Manufacturers [ IndexNum ] = ConsoleInput.readStringObject();
}
for (int IndexNum = 0; IndexNum < Prices.length; IndexNum++)
System.out.println ("Product Code:" + ProductCodes[ IndexNum ] + ",Price :" + Prices[ IndexNum ] + "Manufacturers:" + Manufacturers[ IndexNum ]);
}
public static void main (String[] args) {
PhoneCalc sys = new PhoneCalc (); sys.AddPhonePricesWithLoop ();
}
}

Console Input

import java.io.*;
/** * Write a description of class ConsoleInput here. * * @author (your name) * @version (a version number or a date) */
public class ConsoleInput{
public static char readCharValue () {
BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in));
char c = '\0';
try {
c = Inputter.readLine ().charAt (0);
}
catch (IOException e) {
System.err.println ("Invalid character entered");
}
return c;
}

public static int readIntValue () {
BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in));
int i = 0;
try {
i = Integer.parseInt (Inputter.readLine ());
}
catch (IOException e) {
System.err.println ("Invalid value entered");
}
return i;
}

public static long readLongValue () {
BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in));
long l = 0;
try {
l = Long.parseLong (Inputter.readLine ());
}
catch (IOException e) {
System.err.println ("Invalid value entered");
}
return l;
}

public static float readFloatValue () {
BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in));
float f = 0;
try {
f = Float.parseFloat (Inputter.readLine ());
}
catch (IOException e) {
System.err.println ("Invalid value entered");
}
return f;
}
public static double readDoubleValue () {
BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in));
double d = 0;
try {
d = Double.parseDouble (Inputter.readLine ());
}
catch (IOException e) {
System.err.println ("Invalid value entered");
}
return d;
}

public static String readStringObject () {
BufferedReader Inputter = new BufferedReader (new InputStreamReader (System.in));
String str = null;
try {
str = Inputter.readLine ();
}
catch (IOException e) {
System.err.println ("Invalid text entered");
}
return str;
}
}

Hope it helps.(Works for me)

  suburban train 16:49 04 May 2003

Thank you so much its taken all , did u get my email?

are u sticking around coz i need your help

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

HP Envy x2 review: Hands-on

Iconic New York graphic designer Milton Glaser on his uplifting new subway posters

New iMac Pro release date, UK price & specs rumours

Comment suivre le parcours du père Noël ?