Switch statement help please

I have been advised on this forum that a switch statement in place of the if else etc would be neater. Could someone tell me where the switch statement goes in the code below.
Thanks
Calculator class Calculator.java
class Calculator {
public void Calculator() {
public double workOut(String s1) {
int count = 0, i_s1_len = 0, i_dot=0, i_neg =0;
double d_calc=0,d_num = 0, d_snum=0 ;
String s2 = "", s3 = "", s_num="";
if (s1.length()==0){ //Check for an input eg contains at least one character
System.out.println("Sorry you must input a equation ending in an equals '=' sign");
return 0;
else {
i_s1_len = s1.length();
count = 0; //reset count to zero
//remove spaces s2 becomes the equation
for (count=0; count+1 <= i_s1_len;){
if (s1.charAt(count)==32){
count++;
else{
s2=s2+s1.charAt(count);
count++;
i_s1_len = s2.length();//
// check final character is an "=" sign
if (s2.endsWith("=")){
else{
System .out.println( "Sorry your equation must end with an = sign ");
return 0;
// Checking if characters in the equation are legal eg 1-9 or ()-+/*. or the = sign is only at the end.
count = 0; //reset
for (count=0; count+1 <= i_s1_len;){
if ((s2.charAt(count)>39)&(s2.charAt(count)<58)){
count++;
else if ((s2.charAt(count)==61) & (count != i_s1_len-1)) {
System.out.println("Operator'=' is in two places ");
return 0;
else{
count++;
// Selecting Calculation type +-*/ and calculation Type and conversion
for (count=0; count+1 <= i_s1_len;){
//Addition calculation 43 = +
if (s2.charAt(count)== 43){
s3="+";
// Subtraction Calculation 45 = -
else if (s2.charAt(count)== 45){
s3="-";
// check for minus minus
if (s2.charAt(count+1)== 45){
s3="+";
// multiplication Calculation 42 = *
else if (s2.charAt(count)== 42){
s3="*";
// Division Calculation 47 =/
else if (s2.charAt(count)== 47){
s3="/";
//Get String for conversion to number
else s_num=s_num+s2.charAt(count);{
count++;
// Transfer number to single varable
while ((s2.charAt(count)>47)&(s2.charAt(count)<58)||(s2.charAt(count)==46)){
s_num=s_num+s2.charAt(count);
count++;
//check for multiple decimal points
if (s2.charAt(count-1)==46){
i_dot++;
if (i_dot > 1){
System.out.println("One of your numbers contains two decimals points ");
return 0;
i_dot=0; //reset decimal counter
// Get opperator + - * /
if (s3 =="+"){
d_num = d_num + Double.parseDouble(s_num);
else if (s3 =="-"){
d_num = d_num - Double.parseDouble(s_num);
else if (s3 =="*"){
d_num = d_num * Double.parseDouble(s_num);
else if (s3 =="/"){
if (Double.parseDouble(s_num)==0){
System.out.println("You are trying to divide by Zero which is infinity");
return 0;
d_num = d_num / Double.parseDouble(s_num);
else{
d_num = Double.parseDouble(s_num);
s_num="";
if (s2.length()==count+1) {
return d_num;
return d_num;

Instead of writing
if (x == 1)
    // do this
else if (x == 2)
    // do that
else
    // do the otheryou can write
switch (x) {
case 1:
    // do this
    break;
case 2:
    // do that
    break;
default:
    // do the other
    break;
}

Similar Messages

  • Having problem with switch statement..please help

    here my question :
    GUI-based Pay Calculator
    A company pays its employees as executives (who receive a fixed weekly salary) and hourly workers (who receive a fixed hourly salary for the first 40 hours they work in a week, and 1.5 times their hourly wage for overtime worked).
    Each category of employee has its own paycode :
    ?     Paycode 1 for executives
    ?     Paycode 2 for hourly workers
    Write a GUI-based application to compute the weekly pay for each employee. Use switch to compute each employee?s pay based on that employee?s paycode.
    Use CardLayout layout manager to display appropriate GUI components. Obtain the employee name, employee paycode and other necessary facts from the user to calculate the employee?s pay based on the employee paycode:
    ?     For paycode 1, obtain the weekly salary.
    ?     For paycode 2, obtain the hourly salary and the number of hours worked.
    You may obtain other information which you think is necessary from the user.
    Use suitable classes for the GUI elements. (You can use javax.swing package or java.awt package for the GUI elements.)
    here my code so far :
    import java.awt.;*
    import java.awt.event.;*
    import javax.swing.;*
    *public class PayrollSystem implements ItemListener {*
    JPanel cards, JTextField, textField1, JLabel, label1;
    final static String EXECUTIVEPANEL = "1.EXECUTIVE";
    final static String HOURLYPANEL = "2.HOURLY WORKER";
    public void addComponentToPane(Container pane)
    *//Put the JComboBox in a JPanel to get a nicer look.*
    JPanel comboBoxPane = new JPanel(); //use FlowLayout
    JPanel userNameAndPasswordPane = new JPanel();
    *// User Name JLabel and JTextField*
    userNameAndPasswordPane.add(new JLabel("NAME"));
    JTextField textField1 = new JTextField(25);
    userNameAndPasswordPane.add(textField1);
    *String comboBoxItems[] = { EXECUTIVEPANEL, HOURLYPANEL };*
    JComboBox cb = new JComboBox(comboBoxItems);
    cb.setEditable(false);
    cb.addItemListener(this);
    comboBoxPane.add(cb);
    *//Create the "cards".*
    JPanel card1 = new JPanel();
    card1.add(new JLabel("WEEKLY SALARY"));
    card1.add(new JTextField(6));
    card1.add(new JLabel("TOTAL PAY"));
    card1.add(new JTextField(8));
    card1.add(new JButton("CALCULATE"));
    JPanel card2 = new JPanel();
    card2.add(new JLabel("HOURLY SALARY"));
    card2.add(new JTextField(6));
    card2.add(new JLabel("TOTAL HOURS WORK"));
    card2.add(new JTextField(8));
    card2.add(new JButton("CALCULATE"));
    *//Create the panel that contains the "cards".*
    cards= new JPanel(new CardLayout());
    cards.add(card1, EXECUTIVEPANEL);
    cards.add(card2, HOURLYPANEL);
    pane.add(comboBoxPane, BorderLayout.PAGE_START);
    pane.add(userNameAndPasswordPane, BorderLayout.CENTER);
    pane.add(cards, BorderLayout.PAGE_END);
    public void itemStateChanged(ItemEvent evt)
    CardLayout cl = (CardLayout)(cards.getLayout());
    cl.show(cards, (String)evt.getItem());
    ** GUI created*
    *private static void createAndShowGUI() {*
    *//Make sure we have nice window decorations.*
    JFrame.setDefaultLookAndFeelDecorated(true);
    *//Create and set up the window.*
    JFrame frame = new JFrame("GUI PAY CALCULATOR");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    *//Create and set up the content pane.*
    PayrollSystem demo = new PayrollSystem();
    demo.addComponentToPane(frame.getContentPane());
    *//Display the window.*
    frame.pack();
    frame.setVisible(true);
    *public static void main(String[] args) {*
    *//Schedule a job for the event-dispatching thread:*
    *//creating and showing this application's GUI.*
    *javax.swing.SwingUtilities.invokeLater(new Runnable() {*
    *public void run() {*
    createAndShowGUI();
    HOW CAN I PERFORM THE SWITCH STATEMENT INSIDE THIS CODE TO LET IT FULLY FUNCTIONAL..?
    I MUST PERFORM THE SWITCH STATEMENT LIKE IN THE QUESTION..
    PLEASE HELP ME..REALLY APPRECIATED...TQ

    hi
    A switch works with the byte, short, char, and int primitive data types. So you can simply give the
    switch (month) {
                case 1: 
                            System.out.println("January");
                            break;
                case 2:  {
                            System.out.println("February");
                             break;
                case 3: {
                              System.out.println("March");
                              break;
                             }where month controlls the flow
    moreover u can go to http://www.java-samples.com/java/free_calculator_application_in_java.htm
    for reference, just replace the if statement with switch with correct syntax

  • Switch statement help!!

    ive not done switch statements before, i have a list of months and i have a number from another method which i need to use in this switch statement to obtain the right month.
    example is that the other method returns me with the number 4.....this should give me the month april =D
    im not sure where to go with this.....
    private static String getMonthName(String[] args)
            switch (month)
                case 1:  monthName = "January"; break;
                case 2:  monthName = "February"; break;
                case 3:  monthName = "March"; break;
                case 4:  monthName = "April"; break;
                case 5:  monthName = "May"; break;
                case 6:  monthName = "June"; break;
                case 7:  monthName = "July"; break;
                case 8:  monthName = "August"; break;
                case 9:  monthName = "September"; break;
                case 10: monthName = "October"; break;
                case 11: monthName = "November"; break;
                case 12: monthName = "December"; break;
                default: System.out.println("Invalid month.");break; 
            }

    Either you can do this
          private static String getMonthName(String[] args)
            month=getMonthIndex();
            switch (month)
                case 1:  monthName = "January"; break;
                case 2:  monthName = "February"; break;
                case 3:  monthName = "March"; break;
                case 4:  monthName = "April"; break;
                case 5:  monthName = "May"; break;
                case 6:  monthName = "June"; break;
                case 7:  monthName = "July"; break;
                case 8:  monthName = "August"; break;
                case 9:  monthName = "September"; break;
                case 10: monthName = "October"; break;
                case 11: monthName = "November"; break;
                case 12: monthName = "December"; break;
                default: System.out.println("Invalid month.");break; 
    or this
          private static String getMonthName(String[] args)
            switch (getMonthIndex())
                case 1:  monthName = "January"; break;
                case 2:  monthName = "February"; break;
                case 3:  monthName = "March"; break;
                case 4:  monthName = "April"; break;
                case 5:  monthName = "May"; break;
                case 6:  monthName = "June"; break;
                case 7:  monthName = "July"; break;
                case 8:  monthName = "August"; break;
                case 9:  monthName = "September"; break;
                case 10: monthName = "October"; break;
                case 11: monthName = "November"; break;
                case 12: monthName = "December"; break;
                default: System.out.println("Invalid month.");break; 
                  Assuming that you have a method which returns an index representing a month which in this case i have assumed as getMonthIndex( )

  • Update Statement Help Please

    I'm coming from the MS SQL world LOL
    and Im trying to write an update statement but in Oracle there is no INNER JOIN.
    Can you give me some advice on how to do this please?
    UPDATE employee
    SET employee.name = tmpuser.name
    FROM employee
    INNER JOIN tmpuser
    on tmpuser.emp_id = employtee.emp_id
    Thank you for you help.
    P

    Hi,
    AJR wrote:
    Frank,
    But when we are using the where condition it should update records with the matching ids. right?What your query should do is entirely up to you; I can't answer any questions about that, only you can.
    I have faced this issue earlier.
    WHERE       tmpuser.emp_id = employee.emp_idCan you explain?Not out of context. Post a complete statement.
    If this isn't directly related to user9170886's problem, then it's better to start your own thread.
    I can say a few things about UPDATE statements in general:
    The WHERE clause governs which rows will be UPDATEd. If there is no WHERE clause, all rows in the table will be UPDATEd.
    So
    UPDATE     employee
    SET     employee_name = ( <subquery> )
    ;UPDATEs every row in employee, because the UPDATE statement does not have a WHERE clause. Nothing in the sub-query can change that.
    A sub-query can reference values from its immediate parent, but a parent can't reference values from a sub-query (other than the values actually returned by the sub-query, of course).
    So
    UPDATE     employee
    SET     employee_name = ( <subquery> )
    WHERE     tmpuser.emp_id     = employee.emp_id
    ;causes an error, because there is no table called tmpuser in the main UPDATE statement. Nothing in the sub-query can change that.

  • Comparing Strings with "If" statements : help please. :-)

    I have an assignment for class... and having lots of trouble trying to figure out what I did wrong. I cannot find a solution.. if anyone can help me with this, it'd be much appreciated.
    Assignment Write a program to allow the user to calculate the area and perimeter of a square, or the area and circumference of a circle, or the area of a triangle.
    To do this, the user will enter one of the following characters: S, C, or T. The program should then ask the user for the appropriate information in order to make the calculation, and should display the results of the calculation. See the example program execution shown in class.
    The program should use dialog boxes.
    When expecting an S, C, or T, the program should reject other characters with an appropriate message.
    Get extra points for allowing both the uppercase and lowercase versions of a valid character to work. Name the program ShapesCalc.java.My error codes are
    incomparable types: java.lang.String and Char
    cannot find symbol variable output
    incomparable types: java.lang.String and Char
    incomparable types: java.lang.String and CharI've asked a friend and they said something about Strings cannot be compared in "If" statements... if that is the case.. how is this supposed to be arranged? If you can point me in the right direction, I will be very grateful! :-)
    What I have created so far
    import javax.swing.JOptionPane;
    public class ShapesCalc {
        public static void main(String[] args) {
          //Enter S,C, or T
          String input = JOptionPane.showInputDialog("Enter S,C, or T");
          //If Statements
          //Square
          if (input == 'S'){
               String lengthu = JOptionPane.showInputDialog("Enter length of a square");
               double length = Double.parseDouble(lengthu);
               double area = length * length;
               double perimeter = length * 4;
               String ouput = "The area is " + area + " and the perimeter is " + perimeter;
               JOptionPane.showMessageDialog(null, output);}
          //Circle
          else if (input == 'C'){
               String radiusu = JOptionPane.showInputDialog("Enter the radius of a circle");
               double radius = Double.parseDouble(radiusu);
               double area = 3.14159 * radius * radius;
               double circumference = 2 * 3.14159 * radius;
               String output = "The area is " + area + " and the circumference is " + circumference;
               JOptionPane.showMessageDialog(null, output);}
          //Triangle
          else if (input == 'T'){
               String baseu = JOptionPane.showInputDialog("Enter the base of a triangle");
               double base = Double.parseDouble(baseu);
               String heightu = JOptionPane.showInputDialog("Enter the height of a triangle");
               double height = Double.parseDouble(heightu);
               String output = "The area is " + (base * height) / 2;
               JOptionPane.showMessageDialog(null,output);}
          //Error Message
          else {
               String error = "Incorrect variable please enter S,C, or T only.";
               JOptionPane.showMessageDialog(null,error);}
          //Signature
          String signature = "Rodriguez, Markos has compiled a Java program.";
          JOptionPane.showMessageDialog(null,signature);
    }Edited by: ZambonieDrivor on Feb 22, 2009 6:52 PM

    ZambonieDrivor wrote:
    How would I go about on the extration of a single char from a String to make it comparable, I don't quite understand this part.Read the [Java API|http://java.sun.com/javase/6/docs/api/] for the String class and see what methods it has.
    I will convert the == to equals() method.If you want to compare primitives (ints, chars etc) then using == is fine. Only when comparing objects do you use the equals method.

  • Can't find the geturl Statement HELP PLEASE

    Ok I've been using for 3 years now flash, and of
    course sometimes I have to modify the work of others. So far when I
    intended to modify the target URL for a button I select the button,
    and modify the getURL statement.
    Then I changed to CS3, and I got a menu I need to change...
    actionscript window is no longer where it used to be, but no
    problem, I just clicked F9 locate the button and see the
    actionscript right? WRONG.
    All I see is the stop() and the gotoAndPlay statements but
    not a single gotoURL in all the AS window. I can't seem to find how
    to locate that instruction or even if there is another way to make
    a button go to a URL without the gotoURL instruction, that i'm sure
    has to be there... any idea how to locate the instruction?
    Any help will be highly appreciated.
    Elliot J. Balanza

    Ok here is how they did it, and i must say it was pretty
    clever.
    they created a layer called hit, and put the button there,
    BUT on the layer hit on the first frame they just put a carriage
    return (in the frame)
    Now when you click on the button, they put the normal stuff,
    on release etc. THEN they hide the hit layer and locked it.
    End result, if you tried to see through AS the code, you just
    saw a carriage return, even when the code was in that same frame
    but on the button instance... further more even in the AS pane, you
    only see a carriage return UNTIL you unlock the layer, make it
    visible, and select the button, other wise you just see the
    carriage return...
    Thanks for your feeback dzedward you are the best.

  • Line Stats Help Please.

    Is there anything wrong with these stats CRC, HEC
    ADSL Line Status
    Connection Information
    Line state:    Connected
    Connection time:    4 days, 19:03:09
    Downstream:    18.93 Mbps
    Upstream:    1.125 Mbps
    ADSL Settings
    VPI/VCI:    0/38
    Type:    PPPoA
    Modulation:    G.992.5 Annex A
    Latency type:    Fast
    Noise margin (Down/Up):    6.6 dB / 7.7 dB
    Line attenuation (Down/Up):    20.6 dB / 11.7 dB
    Output power (Down/Up):    20.1 dBm / 12.6 dBm
    FEC Events (Down/Up):    0 / 0
    CRC Events (Down/Up):    15223 / 19552
    Loss of Framing (Local/Remote):    0 / 0
    Loss of Signal (Local/Remote):    0 / 0
    Loss of Power (Local/Remote):    0 / 0
    HEC Events (Down/Up):    41372 / 65882
    Error Seconds (Local/Remote):    7151 / 37986

    I'm on a wired connection, but sometimes I just see poor through put.
    Take this speedtest for example, In previous speed test this used to be mostly a solid graph but as you can see the spikes in this test. (Ok things might be more accurate on the speed tests now so it might be a red herring)
    The ping test graphic below shows that everything should be fine but when I ping from the command line I see the variation.
    I was pinging the bbc domain at around 20 ms then I see a spike of three pings with a max of 143 ms
    C:\Users\Philip>ping bbc.co.uk -t
    Pinging bbc.co.uk [212.58.246.104] with 32 bytes of data&colon;
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=23ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=29ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=23ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=20ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=24ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=23ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=23ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=24ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=111ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=24ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=143ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=90ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=27ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=23ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=24ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=23ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=26ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=20ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=23ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=23ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=22ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=24ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=24ms TTL=51
    Reply from 212.58.246.104: bytes=32 time=21ms TTL=51
    Ping statistics for 212.58.246.104:
        Packets: Sent = 70, Received = 70, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 20ms, Maximum = 143ms, Average = 26ms

  • My mother in law is wanting to make the switch. Help please?

    Gang,
    My mother in law is looking to make the switch to Mac.  She will be utilizing her Mac to create a web page to include lots of content, pictures, video, voice recordings, etc.
    One of the things she wants to puchase is Adobe Creative Suites, I think the premium package.  The system requirements are as follows:
    Mac OS
    Multicore Intel® processor with 64-bit support
    Mac OS X v10.5.8 or v10.6; Mac OS X v10.6 required for Adobe Flash Builder™ 4.5 Premium Edition and Flash Builder integration with Flash Catalyst® and Flash Professional; Mac OS X v10.6.3 required for GPU-accelerated performance in Adobe Premiere Pro
    2GB of RAM (4GB or more recommended)
    26.3GB of available hard-disk space for installation; additional free space required during installation (cannot install on a volume that uses a case-sensitive file system or on removable flash storage devices)
    1280x900 display (1280x1024 recommended) with qualified hardware-accelerated OpenGL graphics card, 16-bit color, and 256MB of VRAM
    Adobe-certified GPU card for GPU-accelerated performance in Adobe Premiere Pro
    Some GPU-accelerated features in Adobe Photoshop require graphics support for Shader Model 3.0 and OpenGL 2.0
    7200 RPM hard drive for editing compressed video formats; RAID 0 for uncompressed
    Core Audio–compatible sound card
    DVD-ROM drive compatible with dual-layer DVDs (SuperDrive for burning DVDs; external Blu-ray burner for creating Blu-ray Disc media)
    Java Runtime Environment 1.6
    Eclipse 3.6.1 Cocoa version required for plug-in installation
    QuickTime 9 software required for QuickTime and multimedia features
    Adobe Flash Player 10 software required to export SWF files and to play back DVD projects exported as SWF files
    Broadband Internet connection required for online services and to validate Subscription Edition (if applicable) on an ongoing basis*
    Visit the NVIDIA website for system requirements and compatibility. The list of graphics cards that are compatible with Adobe Premiere Pro CS5 is updated on a regular basis.
    Can anyone recommend which machine and which upgrades would be needed to make sure this program would run ok?
    She definitely wants an iMac.  My household runs Macs but we aren't tech savy enough to know what all of the above requirements mean.  Obviously there aren't a lot of customization options when purchasing a Mac so I'm not sure if it will require aftermarket type stuff.
    Any information would be greatly appreciated!
    Thanks!
    Chad

    iMacs are great machines. The Adobe CS suite will work on any new or older iMac.  iMacs have great video cards as well. I would suggest that once you buy the iMac, add more memory. Buying it directly from Apple is quite expensive but places like Other World Computing sell excellent memory at great prices. I don't work for them, but I am a long time customer. I love my iMac. The screen is just fabulous.

  • Won't reset, and keep telling me to switch cables - help please!

    i have a 5 gen (video) iPod and i want to restore it to its factory settings, I place it in my dock open up the ipod updater software and it tells me 'I must connect using firewire to restore this iPod', This I do, and when I drop it into my Firewire dock the screen on my iPod says 'firewire connections are not supported, to transfer songs, connect the USb cable provided' - after about 6 times on the merry go round i have decided to seek help, anyone with any ideas.
    Can I restore with just the ipod? USB

    restore the ipod by using the click wheel, like i do
    when i reset it?
    That's not possible. Do you have another computer you can use to do the restore? Maybe another one in your house or at work?

  • SQL insert statement help please

    alternative is to have the table with field dateadd with default value of getdate()   - then do not include in your insert statement - then the modify date use and update - starting point - my two cetns

    Hi all I'm trying to go a little out of my comfort level here and was hoping for some advice. I have a sql table that has 2 date fields. an add and a modified. If the modified date is null then I want to calculate on the date added. Otherwise I'd like to calculate on the modified date.
    Here is a simplified version of what I'm trying to accomplish.
    Hope it makes sense what I'm trying to do.
    SQLSELECT field1,field2.... ,dateAdded , dateModifiedINTO tblOutputFROM tblInput/* some pseudo code here */WHERE (if dateModified not null then ( dateModified

  • HELP -menu using a switch statement

    Hello to all. I'm new to the Java world, but currently taking my first Java class online. Not sure if this is the right place, but I need some help. In short I need to write a program that gives the user a menu to chose from using a switch statement. The switch statement should include a while statement so the user can make more than one selection on the menu and provide an option to exit the program.
    With in the program I am to give an output of all counting numbers (6 numbers per line).
    Can anyone help me with this?? If I'm not asking the right question please let me know or point me in the direction that can help me out.
    Thanks in advance.
    Here is what I have so far:
    import java.util.*;
    public class DoWhileDemo
         public static void main(String[] args)
              int count, number;
              System.out.println("Enter a number");
              Scanner keyboard = new Scanner (System.in);
              number = keyboard.nextInt();
              count = number;
              do
                   System.out.print(count +",");
                   count++;
              }while (count <= 32);
              System.out.println();
              System.out.println("Buckle my shoe.");
    }

    Thanks for the reply. I will tk a look at the link that was provided. However, I have started working on the problem, but can't get the 6 numbers per line. I am trying to figure out the problem in parts. Right now I'm working on the numbers, then the menu, and so on.
    Should I tk this approach or another?
    Again, thanks for the reply.

  • Methods & Switch Statement in java.. HELP!!

    hi all...
    i am having a slight problem as i am constructing a method --> menu() which handles displaying
    menu options on the screen, prompting the user to select A, B, C, D, S or Q... and then returns the user
    input to the main method!!!
    i am having issues with switch statement which processes the return from menu() methd,,,
    could you please help?!!
    here is my code...
    import java.text.*;
    import java.io.*;
    public class StudentDriver
       public static void main(String[] args) throws IOException
          for(;;)
             /* Switch statement for menu manipulation */
             switch(menu())
                   case A: System.out.println("You have selected option A");
                                  break;
                   case B: System.out.println("You have selected option B");
                                  break;
                   case C: System.out.println("You have selected option C");
                                  break;
                   case D: System.out.println("You have selected option D");
                                  break;
                   case S: System.out.println("You have selected option S");
                                  break;
                   case Q: System.out.println("\n\n\n\n\n\n\t\t Thank you for using our system..." +
                                                                    "\n\n\t\t\t Good Bye \n\n\n\n");
                                  exit(0);    
       static char menu()
          char option;
          BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));       
          System.out.println("\n\n");
          System.out.println("\n\t\t_________________________");
          System.out.println("\t\t|                       |");
          System.out.println("\t\t| Student Manager Menu  |");
          System.out.println("\t\t|_______________________|");
          System.out.println("\n\t________________________________________");
          System.out.println("\t| \t\t\t\t\t|");
          System.out.println("\t| Add new student\t\t A \t|");
          System.out.println("\t| Add credits\t\t\t B \t|");
          System.out.println("\t| Display one record\t\t C \t|");
          System.out.println("\t| Show the average credits\t D \t|");
          System.out.println("\t| \t\t\t\t\t|");
          System.out.println("\t| Save the changes\t\t S \t|");
          System.out.println("\t| Quit\t\t\t\t Q \t|");
          System.out.println("\t|_______________________________________|\n");
          System.out.print("\t  Your Choice: ");
          option = stdin.readLine();
             return option;
    }Thanking your help in advance...
    yours...
    khalid

    Hi,
    There are few changes which u need to make for making ur code work.
    1) In main method, in switch case change case A: to case 'A':
    Characters should be represented in single quotes.
    2) in case 'Q' change exit(0) to System.exit(0);
    3) The method static char menu() { should be changed to static char menu() throws IOException   {
    4) Change option = stdin.readLine(); to
    option = (char)stdin.read();
    Then compile and run ur code. This will work.
    Or else just copy the below code
    import java.text.*;
    import java.io.*;
    public class StudentDriver{
         public static void main(String[] args) throws IOException {
              for(;;) {
                   /* Switch statement for menu manipulation */
                   switch(menu()) {
                        case 'A': System.out.println("You have selected option A");
                        break;
                        case 'B': System.out.println("You have selected option B");
                        break;
                        case 'C': System.out.println("You have selected option C");
                        break;
                        case 'D': System.out.println("You have selected option D");
                        break;
                        case 'S': System.out.println("You have selected option S");
                        break;
                        case 'Q':
                        System.out.println("\n\n\n\n\n\n\t\t Thank you for using our system..." +
                        "\n\n\t\t\t Good Bye \n\n\n\n");
                        System.exit(0);
         static char menu() throws IOException {
              char option;
              BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
              System.out.println("\n\n");
              System.out.println("\n\t\t_________________________");
              System.out.println("\t\t| |");
              System.out.println("\t\t| Student Manager Menu |");
              System.out.println("\t\t|_______________________|");
              System.out.println("\n\t________________________________________");
              System.out.println("\t| \t\t\t\t\t|");
              System.out.println("\t| Add new student\t\t A \t|");
              System.out.println("\t| Add credits\t\t\t B \t|");
              System.out.println("\t| Display one record\t\t C \t|");
              System.out.println("\t| Show the average credits\t D \t|");
              System.out.println("\t| \t\t\t\t\t|");
              System.out.println("\t| Save the changes\t\t S \t|");
              System.out.println("\t| Quit\t\t\t\t Q \t|");
              System.out.println("\t|_______________________________________|\n");
              System.out.print("\t Your Choice: ");
              option = (char)stdin.read();
              return option;
    regards
    Karthik

  • HELP A COMPLETE NOOB! Java Switch Statement?

    Hi, I am trying to use a simple switch statement and I just cant seem to get it to work?;
    import java.util.Scanner;
    public class Month {
    public static void main(String[] args) {
    String message;
    Scanner scan = new Scanner(System.in);
    System.out.println("Enter a number:");
    message = scan.nextLine();
    int month = 8;
    if (month == 1) {
    System.out.println("January");
    } else if (month == 2) {
    System.out.println("February");
    switch (month) {
    case 1: System.out.println("January"); break;
    case 2: System.out.println("February"); break;
    case 3: System.out.println("March"); break;
    case 4: System.out.println("April"); break;
    case 5: System.out.println("May"); break;
    case 6: System.out.println("June"); break;
    case 7: System.out.println("July"); break;
    case 8: System.out.println("August"); break;
    case 9: System.out.println("September"); break;
    case 10: System.out.println("October"); break;
    case 11: System.out.println("November"); break;
    case 12: System.out.println("December"); break;
    default: System.out.println("Invalid month.");break;}
    Please can anyone help, all I want is to enter a number and the corresponding month to appear. Thank you.

    This will work.
    import java.util.Scanner;
    public class Month {
    public static void main(String[] args) {
    // read user input
    Scanner scan = new Scanner(System.in);
    System.out.println("Enter a number:");
    int month = scan.nextInt();
    // print the month
    switch (month) {
    case 1: System.out.println("January"); break;
    case 2: System.out.println("February"); break;
    case 3: System.out.println("March"); break;
    case 4: System.out.println("April"); break;
    case 5: System.out.println("May"); break;
    case 6: System.out.println("June"); break;
    case 7: System.out.println("July"); break;
    case 8: System.out.println("August"); break;
    case 9: System.out.println("September"); break;
    case 10: System.out.println("October"); break;
    case 11: System.out.println("November"); break;
    case 12: System.out.println("December"); break;
    default: System.out.println("Invalid month.");break;}
    }

  • Java Program.. HELP  (switch statement)

    I need help on fixing this program for school.ive looked at information online but i still do not see what i am doing wrong.
    The College Rewards Program is based on a student�s achievements on the ACT Test. Students that have excelled on the test are going to be rewarded for the hard work that they put into high school and studying for the exam. The following are the rewards that will be given to students. They are cumulative, and they get all rewards below their score.
    1. 35-36 $100 a week spending money
    2. 33-34 Free computer
    3. 31-32 $10,000 free room and board
    4. 25-30 $5000 off the years tuition
    5. 21-24 $500 in free books per year
    6. 17-20 Free notebook
    7. 0-16 Sorry, no rewards, please study and try taking the ACT again.
    Make a prompt so the user is asked for their ACT score( be careful).
    Change the ACT score into a number
    Then have the program use that number to display a message about the Rewards program.
    Sample output:
    What was your score on the ACT: 44
    Entry error, please enter a number from 0 to 36.      (error trap wrong numbers)
    What was your score on the ACT: 27
    You got a 27 on the ACT, your rewards are:      ( have it number the rewards)
    1. $5,000 off the year�s tuition
    2. $500 dollars a year in books
    3. A free notebook
    Congratulations on your hard work and good score.
    import java.util.Scanner;
    import java.text.*;
    public class Act
        public static void main (String [] args)
             Scanner scan = new Scanner( System.in );
              int score,reward;
              score=0;
              boolean goodnum;
              do
                      System.out.println( "What was your ACT score? " );
                              score = scan.nextInt() ;
              if (score >0 || score <36) goodnum = true;      
                   else
                    System.out.println ("Please enter the correct number");
                              goodnum=false;     
                    while (score<0 || score>36) {
                              if (score==35 || score==36) reward=1;
                                   else if (score ==34 || score score==33) reward=2;
                                        else if (score==32 || score==31) reward=3;
                                             else if (score>=25 && score<=30) reward=4;
                                                  else if (score>=21 && score<=24) reward=5;
                                                     else if (score>=17 && score<=20) reward=6;
                                                              else reward=7;
        c=0
        switch (reward) {
        case 1: $100 a week spending money
                  c++
                  System.out.println ("$100 a week spending money");     
        case 2:     Free computer
                  c++
                  System.out.println ("Free computer");     
            case 3:      $10,000 free room and board
                  c++
                  System.out.println ("$10,000 free room and board");
        case 4:      $5000 off the years tuition
              c++
              System.out.println ("$5000 off the years tuition");
        case 5:      $500 in free books per year
              c++
               System.out.println ("$500 in free books per year");
        case 6:      Free notebook
              c++
              System.out.println ("Free notebook");
        case 7:      Free notebook
              c++
              System.out.println ("Sorry, no rewards, please study and try taking the ACT again.");
              break;
        default:
             System.out.println ("Sorry, no rewards, please study and try taking the ACT again.");
            break;
        }

    There are some strange things going on here that could be fixed, so I'll just put my version of how i'd handle this up.
    import java.util.Scanner;
    import java.text.*; // is this really needed? Scanner's the only class I see
    public class Act {
      public static void main( String[] args ) {
        Scanner scan = new Scanner( System.in );
        int score, reward; // don't need to set a value yet
        boolean goodnum;
        do {
          System.out.println( "What was your ACT score? " );
          score = scan.nextInt();
          if ( score >= 0 && score <= 36 ) goodnum = true; // note the && and =s
          else {
            System.out.println( "Please enter a valid number (between 0 and 36)." );
            goodnum = false;
        } while ( !goodnum ); // when this loop finished, the number will be between 0 and 36, a good number
        if ( score >= 35 ) reward = 1;      // save yourself the typing, by now score must be between 0 and 36
        else if ( score >= 33 ) reward = 2; // so just go down with else ifs.
        else if ( score >= 31 ) reward = 3; // this will only reach the lowest point.
        else if ( score >= 25 ) reward = 4;
        else if ( score >= 21 ) reward = 5;
        else if ( score >= 17 ) reward = 6;
        else reward = 7;
        // what was the c for? reward already tells how well they did
        // You handled the switch statement almost perfectly
        // don't break so that reward progressively adds to the output
        if ( reward >= 6 ) { // this if statement is optional, just for good esteem. You could even take it out of the if{}
          System.out.println( "For your score of "+String.valueOf( score )+" you will be rewarded the following:" );
        switch ( reward ) {
          case 1: // $100/week spending money
            System.out.println( "$100 a week spending money." );
          case 2: // Free computer
            System.out.println( "Free computer." );
          case 3: // $10,000 room and board
            System.out.println( "$10,000 free room and board." );
          case 4: // $5000 off tuition
            System.out.println( "$5000 off the year's tuition." );
          case 5: // $500 in free books per year
            System.out.println( "$500 in free books per year." );
          case 6: // Free notebook
            System.out.println( "Free notebook." );
            break; // break here to keep away from discouraging the fine score
          case 7: // since 7 and default are the same result, ignore this and it'll pass to default
          default: // but technically, since reward must be from 1 to 7, default would never explicitly be called
            System.out.println( "Sorry, no rewards. Please study and try taking the ACT again." );
            break; // likely this break is unneccessary
    }That works in my head, hope it works on your computer.

  • Help with Switch statements using Enums?

    Hello, i need help with writing switch statements involving enums. Researched a lot but still cant find desired answer so going to ask here. Ok i'll cut story short.
    Im writing a calculator program. The main problem is writing code for controlling the engine of calculator which sequences of sum actions.
    I have enum class on itself. Atm i think thats ok. I have another class - the engine which does the work.
    I planned to have a switch statement which takes in parameter of a string n. This string n is received from the user interface when users press a button say; "1 + 2 = " which each time n should be "1", "+", "2" and "=" respectively.
    My algorithm would be as follows checking if its a operator(+) a case carry out adding etc.. each case producing its own task. ( I know i can do it with many simple if..else but that is bad programming technique hence im not going down that route) So here the problem arises - i cant get the switch to successfully complete its task... How about look at my code to understand it better.
    I have posted below all the relevant code i got so far, not including the swing codes because they are not needed here...
    ValidOperators v;
    public Calculator_Engine(ValidOperators v){
              stack = new Stack(20);
              //The creation of the stack...
              this.v = v;          
    public void main_Engine(String n){
           ValidOperators v = ValidOperators.numbers;
                    *vo = vo.valueOf(n);*
         switch(v){
         case Add: add();  break;
         case Sub: sub(); break;
         case Mul: Mul(); break;
         case Div: Div(); break;
         case Eq:sum = stack.sPop(); System.out.println("Sum= " + sum);
         default: double number = Integer.parseInt(n);
                       numberPressed(number);
                       break;
                      //default meaning its number so pass it to a method to do a job
    public enum ValidOperators {
         Add("+"), Sub("-"), Mul("X"), Div("/"),
         Eq("="), Numbers("?"); }
         Notes*
    It gives out error: "No enum const class ValidOperators.+" when i press button +.
    It has nothing to do with listeners as it highlighted the error is coming from the line:switch(v){
    I think i know where the problem is.. the line "vo = vo.valueOf(n);"
    This line gets the string and store the enum as that value instead of Add, Sub etc... So how would i solve the problem?
    But.. I dont know how to fix it. ANy help would be good
    Need more info please ask!
    Thanks in advance.

    demo:
    import java.util.*;
    public class EnumExample {
        enum E {
            STAR("*"), HASH("#");
            private String symbol;
            private static Map<String, E> map = new HashMap<String, E>();
            static {
                put(STAR);
                put(HASH);
            public String getSymbol() {
                return symbol;
            private E(String symbol) {
                this.symbol = symbol;
            private static void put(E e) {
                map.put(e.getSymbol(), e);
            public static E parse(String symbol) {
                return map.get(symbol);
        public static void main(String[] args) {
            System.out.println(E.valueOf("STAR")); //succeeds
            System.out.println(E.parse("*")); //succeeds
            System.out.println(E.parse("STAR")); //fails: null
            System.out.println(E.valueOf("*")); //fails: IllegalArgumentException
    }

Maybe you are looking for

  • How do I delete a previous exported from an app calendar?

    I've exported a calendar, from an app, to my iPhone calendar. Now, I'm having problems in removing it from the iPhone. The option to delete it simply don't appear, as usually appears. Someone please help me  

  • Mac Backup on Windows Server (Wildcard issues)

    So our Art department is suppose to be backing up all files to a Windows Server. Which brings this problem. Of course being designers we use wildcard symbols on naming files which the windows server won't allow. So when we attempt to backup, the copy

  • Deleted text appears in playback

    Hi Using FCE HD 3.5, I generated a crawl text that I rendered then later deleted. There is no clip showing in the timeline however the text still appears during playback. I am unable to highlight the text in the canvas and am at a loss. thx g5 quad  

  • How to change color .. help

    problem: How can i change the color of the words as i type? example: you know in most programming languages, such as JLE or visual studio, wherein when you type a reserved word, the color changes like when you type the word "int", as well as when you

  • Itunes won't install due to permission error???

    iTunes will not let me install because every time this thing pops up and says I do not have permission to the files. Some HKEY file but I am the administrator. When I go to the registry edit it will not let me change who has permission.I also cannot