Any java programmers in the fourum today

  suburban train 19:28 03 May 03
Locked

Is there any java programmers in the forum that can help me a with some coding if not anyone know any other fourums

  LastChip 19:32 03 May 03

click here Look under Forums.

  Mysticnas 19:53 03 May 03

post your query here... if i can help i will.

Nas

  suburban train 20:17 03 May 03

cheers mate give me a sec to get the coding

  suburban train 20:20 03 May 03

this is what i am trying to do to the class called PhoneClac:

Modify the loop in the method AddPhonesWithLoop so that it obtains the ProductCode and Manufacturer information. This requires adding statements in the loop that prompts the user to input the ProductCode, reads the keyboard for a String and stores this string in the ProductCodes array. There will be similar statements for the Manufacturer array. For example, to obtain the ProductCode the following statements would be added after the for loop statement, for (int IndexNum = 0; IndexNum < Prices.length; IndexNum++)

System.out.println (ýPlease enter the product codeý);
ProductCode = ConsoleInput.readStringValue ();
ProductCodes[ IndexNum ] = ProductCode;

Note, that you will also have to create a local variable called ProductCode that stores the input from the user, like Price does for the price value. This local variable will be a String. Similarly you will have to add statements that prompt for the manufacturer, obtain the manufacturer as a String and store the String the Manufacturer array.


/** * Write a description of class PhoneCalc here. * * (Abol Akrami) * */public class PhoneCalc{ private double[] Prices = new double[ 15 ]; private String[] ProductCodes = new String[ 15 ]; private String[] Manufacturers = new String[ 15 ]; public PhoneCalc() {} public void AddPhonePricesWithLoop () { double Price; for (int IndexNum = 0; IndexNum < 15; IndexNum++) { System.out.println("Please enter price of phone"); Price = ConsoleInput.readDoubleValue (); Prices [ IndexNum ] = Price; } for (int IndexNum = 0; IndexNum <Prices.length; IndexNum++) System.out.println ("The cost of the phone is "+ Prices[ IndexNum ]); } public static void main (String[] args) { PhoneCalc sys = new PhoneCalc (); sys.AddPhonePricesWithLoop (); }}


the class to go with this is called Console Input but dont change it as we have to work with it.



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; }}[\co

  suburban train 20:21 03 May 03

last line should say

{ System.err.println ("Invalid text entered"); } return str; }}[\code]

  Mysticnas 20:36 03 May 03

i'll have a propper look at it soon. just need to get some work done and i'll check it out.

Nas

  suburban train 20:40 03 May 03

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

How to get Windows 10 for free | How to install Windows 10: There is still a way to avoid paying…

1995-2015: How technology has changed the world in 20 years

Hands-on with the Star Wars fighting drones you can fly yourself

15 macOS Sierra tips | How to use macOS Sierra: Secret tricks and best new features in Apple's new…