Jump to content

alienA2

Members
  • Posts

    74
  • Joined

  • Last visited

About alienA2

  • Birthday 09/18/1983

Previous Fields

  • Languages
    Acrobat Javascript; mySQL (Oracle)

Profile Information

  • Location
    Cape Town
  • Interests
    Music and Technology

alienA2's Achievements

Newbie

Newbie (1/7)

19

Reputation

  1. According to the C++ book I have yes lol
  2. Hi My program is not calculating the wages correctly. Can somebody please tell me why??? /** PayCheck Program* This program computes an employee's wages for the week*/import java.util.Scanner;import static java.lang.System.in;import static java.lang.System.out;class mainPayCheckProg{ public static void main(String args[]) { // create an instance of the class or object payCheckMethods aWage = new payCheckMethods(); Scanner prompt_user = new Scanner(in); double payRate; double hours; double wages; int empNum; double max_hours = 40.0; double overtime = 1.5; out.print("Enter Employee Number: "); empNum = prompt_user.nextInt(); out.print("Enter Pay Rate: "); payRate = prompt_user.nextDouble(); out.print("Enter Hours Worked: "); hours = prompt_user.nextDouble(); if (hours > max_hours) { wages = (max_hours * payRate) + (hours - max_hours) * payRate * overtime; } else { wages = max_hours * payRate; } out.print("Employee Number: "); out.println(empNum); out.print("Pay rate: "); out.println(payRate); out.print("Hours worked: "); out.println(hours); out.print("Wages: "); out.println(wages); }}
  3. Hello As as Beginner Programmer in Java, where do you start if you want to start building applications??? So much out there that one becomes overwhelmed. Do you:a.) Program and copy existing software?b.) Invent something of your own?c.) Collab with another programmer It is like you have the tools,...now what?? lol (By the way if any of you wants to collab on writing software, PM me please thanks.)
  4. Nevermind lol...figured this one out... go to File->Project Properties->RunThen change the text inside Main Class to the actual class name in your code... My program ran after this change. (note: the java code was written in Notepadd++ then tested on Command Prompt. But I would like to do inside NetBeans IDE now).
  5. I know to do this in Command Prompt. But how do you generate a class file in NetBeans?
  6. I have downloaded JCreator to do Java programs. But I am finding it difficult to "see" what I am doing. For example, I have an image design for a interface/GUI that I would like build with Java But JCreator does not have tools where one can select buttons, checkboxes etc etc. Does anybody know a great IDE software for this? More user-friendly, more easier to get started with a design and working your way into programming.
  7. Hi I am trying to run this program that was made for speech recognition. However, it does not run.Tools used: notepadd++; Command Prompt Here is the errors:C:\java_work\JavaVoice>javac JavaVoice.javaJavaVoice.java:14: error: package javax.speech does not existimport javax.speech.AudioException; ^JavaVoice.java:15: error: package javax.speech does not existimport javax.speech.Central; ^JavaVoice.java:16: error: package javax.speech does not existimport javax.speech.EngineException; ^JavaVoice.java:17: error: package javax.speech.synthesis does not existimport javax.speech.synthesis.Synthesizer; ^JavaVoice.java:18: error: package javax.speech.synthesis does not existimport javax.speech.synthesis.SynthesizerModeDesc; ^JavaVoice.java:32: error: cannot find symbol private Synthesizer synth; ^ symbol: class Synthesizer location: class JavaVoiceJavaVoice.java:42: error: package javax.speech does not exist javax.speech.EngineList elist = Central.availableSyntizers(null); ^JavaVoice.java:42: error: cannot find symbol javax.speech.EngineList elist = Central.availableSyntizers(null); ^ symbol: variable Central location: class JavaVoiceJavaVoice.java:46: error: cannot find symbol SynthesizerModeDesc desc = (SynthesizerModeDeelist.elementAt(i); ^ symbol: class SynthesizerModeDesc location: class JavaVoiceJavaVoice.java:46: error: cannot find symbol SynthesizerModeDesc desc = (SynthesizerModeDeelist.elementAt(i); ^ symbol: class SynthesizerModeDesc location: class JavaVoiceJavaVoice.java:50: error: cannot find symbol synth = Central.createSynthesizer((SynthesizerModeDeslist.get(preferences.get("voice.selected",""))); ^ symbol: class SynthesizerModeDesc location: class JavaVoiceJavaVoice.java:50: error: cannot find symbol synth = Central.createSynthesizer((SynthesizerModeDeslist.get(preferences.get("voice.selected",""))); ^ symbol: variable Central location: class JavaVoiceJavaVoice.java:54: error: cannot find symbol catch(EngineException ex) { ^ symbol: class EngineException location: class JavaVoiceJavaVoice.java:57: error: cannot find symbol catch(AudioException ex) { ^ symbol: class AudioException location: class JavaVoiceJavaVoice.java:129: error: cannot find symbol synth = Central.createSynthesizer((SyesizerModeDesc) list.get(str)); ^ symbol: class SynthesizerModeDescJavaVoice.java:129: error: cannot find symbol synth = Central.createSynthesizer((SyesizerModeDesc) list.get(str)); ^ symbol: variable CentralJavaVoice.java:133: error: cannot find symbol catch(EngineException ex) { ^ symbol: class EngineExceptionJavaVoice.java:136: error: cannot find symbol catch(AudioException ex) { ^ symbol: class AudioExceptionJavaVoice.java:149: error: cannot find symbol catch(EngineException ex) { ^ symbol: class EngineExceptionJavaVoice.java:182: error: cannot find symbol SynthesizerModeDesc desc1 = (SynthesizerModeDesc) obj1; ^ symbol: class SynthesizerModeDesc location: class JavaVoiceJavaVoice.java:182: error: cannot find symbol SynthesizerModeDesc desc1 = (SynthesizerModeDesc) obj1; ^ symbol: class SynthesizerModeDesc location: class JavaVoiceJavaVoice.java:183: error: cannot find symbol SynthesizerModeDesc desc2 = (SynthesizerModeDesc) obj2; ^ symbol: class SynthesizerModeDesc location: class JavaVoiceJavaVoice.java:183: error: cannot find symbol SynthesizerModeDesc desc2 = (SynthesizerModeDesc) obj2; ^ symbol: class SynthesizerModeDesc location: class JavaVoiceJavaVoice.java:194: error: cannot find symbol catch(EngineException ex) { ^ symbol: class EngineException location: class JavaVoice.AppCloserNote: JavaVoice.java uses unchecked or unsafe operations.Note: Recompile with -Xlint:unchecked for details.24 errors Here is the code:import java.awt.BorderLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.io.File;import java.io.FileReader;import java.io.IOException;import java.util.Collections;import java.util.Comparator;import java.util.Locale;import java.util.Hashtable;import java.util.prefs.Preferences;import javax.speech.AudioException;import javax.speech.Central;import javax.speech.EngineException;import javax.speech.synthesis.Synthesizer;import javax.speech.synthesis.SynthesizerModeDesc;import javax.swing.DefaultComboBoxModel;import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.JFileChooser;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JScrollPane;import javax.swing.JTextField;import javax.swing.JTextArea;import javax.swing.JToolBar;public class JavaVoice extends JFrame implements Comparator { private Synthesizer synth; private File readFile = null; Preferences preferences = Preferences.userRoot().node("dlb/JavaVoice"); JComboBox voices; Hashtable list; public JavaVoice() { super("Java Voice Synthesizer"); addWindowListener(new AppCloser()); DefaultComboBoxModel model = new DefaultComboBoxModel(); try { javax.speech.EngineList elist = Central.availableSynthesizers(null); list = new Hashtable(elist.size()); Collections.sort(elist,this); for (int i=0;i<elist.size();i++) { SynthesizerModeDesc desc = (SynthesizerModeDesc)elist.elementAt(i); model.addElement(desc.getModeName()); list.put(desc.getModeName(),desc); } synth = Central.createSynthesizer((SynthesizerModeDesc) list.get(preferences.get("voice.selected",""))); synth.allocate(); synth.resume(); } catch(EngineException ex) { ex.printStackTrace(); } catch(AudioException ex) { ex.printStackTrace(); } final JTextArea textArea = new JTextArea(); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); JScrollPane scrollPane = new JScrollPane(textArea); getContentPane().add(scrollPane,BorderLayout.CENTER); JToolBar toolBar = new JToolBar(); JButton button = new JButton("Open"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { JFileChooser fileChooser = new JFileChooser(preferences.get("voice.openDirectory",System.getProperty("user.dir"))); if(fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { readFile = fileChooser.getSelectedFile(); preferences.put("voice.openDirectory",readFile.getParent()); try { FileReader reader = new FileReader(readFile); textArea.read(reader,readFile.getName()); reader.close(); } catch(IOException ex) { ex.printStackTrace(); } } } }); toolBar.add(button); button = new JButton("Clear"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { textArea.setText(""); } }); toolBar.add(button); toolBar.add(button); button = new JButton("Start"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { String str = textArea.getSelectedText(); if(str != null && str.length() > 0) { synth.speakPlainText(str.toLowerCase(),null); textArea.setSelectionStart(0); textArea.setSelectionEnd(0); } else { str = textArea.getText(); synth.speakPlainText(str.toLowerCase(),null); } } }); toolBar.add(button); button = new JButton("Stop"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try { synth.cancel(); } catch(ArrayIndexOutOfBoundsException ex) {} } }); toolBar.add(button); toolBar.addSeparator(); toolBar.add(new JLabel("Voice:")); voices = new JComboBox(model); voices.setSelectedItem(preferences.get("voice.selected","")); voices.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try { synth.deallocate(); String str = (String) voices.getSelectedItem(); preferences.put("voice.selected",str); synth = Central.createSynthesizer((SynthesizerModeDesc) list.get(str)); synth.allocate(); synth.resume(); } catch(EngineException ex) { ex.printStackTrace(); } catch(AudioException ex) { ex.printStackTrace(); } } }); toolBar.add(voices); toolBar.addSeparator(); button = new JButton("Exit"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { try { synth.deallocate(); } catch(EngineException ex) { ex.printStackTrace(); } preferences.putInt("voice.mainWindow.x",getLocation().x); preferences.putInt("voice.mainWindow.y",getLocation().y); preferences.putInt("voice.mainWindow.width",getSize().width); preferences.putInt("voice.mainWindow.height",getSize().height); System.exit(1); } }); toolBar.add(button); getContentPane().add(toolBar,BorderLayout.NORTH); final JTextField textField = new JTextField(); textField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { String txt = textField.getText(); if(txt.length() > 0) { textArea.append(txt+'\n'); synth.speakPlainText(txt, null); textField.setText(""); } } }); getContentPane().add(textField,BorderLayout.SOUTH); int x = preferences.getInt("voice.mainWindow.x",1); int y = preferences.getInt("voice.mainWindow.y",1); int width = preferences.getInt("voice.mainWindow.width",640); int height = preferences.getInt("voice.mainWindow.height",480); setLocation(x,y); setSize(width,height); setVisible(true); } public int compare(Object obj1, Object obj2) { SynthesizerModeDesc desc1 = (SynthesizerModeDesc) obj1; SynthesizerModeDesc desc2 = (SynthesizerModeDesc) obj2; return desc1.getModeName().compareToIgnoreCase(desc2.getModeName()); } public static void main(String args[]) { new JavaVoice(); } class AppCloser extends WindowAdapter { public void windowClosing(WindowEvent ev) { try { synth.deallocate(); } catch(EngineException ex) { ex.printStackTrace(); } System.exit(1); } }}
  8. Please see the code, background image, and the buttons which are currently outside the background image. I would like to find out how to add the buttons inside the the background. tools used: notepadd++ and command prompt. Thanks creation1.zip
  9. H To keep it simple, are you saying .NET is the way to go? Sorry for asking, but is .NET a computer language of its own, or is it C# its langauge?
  10. I got this code that will not run. I took the code from a book for dummies. I understand what it is asking but I do not know why since the book shows this code as if it should work when it runs. Please advice. error:C:\java_prog\mywork\Account>java AccountError: Main method not found in class Account, please define the main method as: public static void main(String[] args) code: import java.text.NumberFormat;import static java.lang.System.out;class Account{ // variable declarations String naam; int dompas; double jousakie; void display() { NumberFormat moola = NumberFormat.getCurrencyInstance(); out.print("The account with last name "); out.print(naam); out.print(" and ID number "); out.print(dompas); out.print(" has balance "); out.println(moola.format(jousakie)); }}
  11. So to kick my friday off, I would like to ask what are the differences in the two languages. I know this might turn to a debate. But I am still a newbie in the Java world. I have been over articles via google searches, and have seen comparisons of the two languages. My question: Can both Languages make software like: Games; Music Production Software; and Business Applications (eg MS Excel). Or is certain software more dependent on a certain language's functionality and packages etc etc.
  12. Why } while (!"Y".equals(myScanner.next().toUpperCase()));Why is the ! character added to the code???
  13. Me again. Modified the code...it seems to work but your opinions are appreciated: /*Do another? Exception in thread "main" java.lang.NullPointerException at AddGuests.main(AddGuests.java:41)*/import java.util.Scanner;import static java.lang.System.in;import static java.lang.System.out;import java.io.File;import java.io.FileNotFoundException;import java.io.PrintStream;class AddGuests{ public static void main(String args[]) throws FileNotFoundException { //Variable declarations Scanner myScanner = new Scanner(in); PrintStream w2d = new PrintStream("GuestList_Report.xls"); int whichRoom, numGuests; int guestsIn[]; char antwoord; guestsIn = new int[10]; //The for loop is assigning zero to the guestsIn variable with the array value as the room number... for (int roomNum = 0; roomNum < 10; roomNum++) { guestsIn[roomNum] = 0; } do { out.print("Room number: "); whichRoom = myScanner.nextInt(); out.print("How many guests? "); numGuests = myScanner.nextInt(); guestsIn[whichRoom] = numGuests; out.println(); out.print("Do another? "); antwoord = myScanner.next(".").charAt(0); //do this while the myscanner variable reads input from user to be Y) } while (antwoord == 'Y' || antwoord == 'y'); out.println("Thank you. Your information has been logged."); //heading to make it look pretty... w2d.println(); w2d.println("Room\tGuests"); for (int roomNum = 0; roomNum < 10; roomNum++) { w2d.print(roomNum); w2d.print("\t"); w2d.println(guestsIn[roomNum]); } }}
  14. Hi I am getting this error. I do not know why. I suspect it has something to do with the do while loop, where it mentions (myScanner.findInLine(".").charAt(0) == 'Y'); . Please advice. error:Do another? Exception in thread "main" java.lang.NullPointerException at AddGuests.main(AddGuests.java:41) code: /*Do another? Exception in thread "main" java.lang.NullPointerException at AddGuests.main(AddGuests.java:41)*/import java.util.Scanner;import static java.lang.System.in;import static java.lang.System.out;class AddGuests{ public static void main(String args[]) { //Variable declarations Scanner myScanner = new Scanner(in); int whichRoom, numGuests; int guestsIn[]; guestsIn = new int[10]; //The for loop is assigning zero to the guestsIn variable with the array value as the room number... for (int roomNum = 0; roomNum < 10; roomNum++) { guestsIn[roomNum] = 0; } do { out.print("Room number: "); whichRoom = myScanner.nextInt(); out.print("How many guests? "); numGuests = myScanner.nextInt(); guestsIn[whichRoom] = numGuests; out.println(); out.print("Do another? "); //do this while the myscanner variable reads input from user to be Y) } while (myScanner.findInLine(".").charAt(0) == 'Y'); //heading to make it look pretty... out.println(); out.println("Room\tGuests"); for (int roomNum = 0; roomNum < 10; roomNum++) { out.print(roomNum); out.print("\t"); out.println(guestsIn[roomNum]); } }}
×
×
  • Create New...