Need help with calculator project for an assignment...

Hi all, I please need help with my calculator project that I have to do for an assignment.
Here is the project's specifications that I need to do"
"""Create a console calculator applicaion that:
* Takes one command line argument: your name and surname. When the
program starts, display the date and time with a welcome message for the
user.
* Display all the available options to the user. Your calculator must include
the arithmetic operations as well as at least five scientific operations of the
Math class.
-Your program must also have the ability to round a number and
truncate it.
-When you multiply by 2, you should not use the '*' operator to perform the
operation.
-Your program must also be able to reverse the sign of a number.
* Include sufficient error checking in your program to ensure that the user
only enters valid input. Make use of the String; Character, and other
wrapper classes to help you.
* Your program must be able to do conversions between decimal, octal and
hex numbers.
* Make use of a menu. You should give the user the option to end the
program when entering a certain option.
* When the program exits, display a message for the user, stating the
current time, and calculate and display how long the user used your
program.
* Make use of helper classes where possible.
* Use the SDK to run your program."""
When the program starts, it asks the user for his/her name and surname. I got the program to ask the user again and again for his/her name and surname
when he/she doesn't insert anything or just press 'enter', but if the user enters a number for the name and surname part, the program continues.
Now my question is this: How can I restrict the user to only enter 'letters' (and spaces of course) but allow NO numbers for his/her surname??
Here is the programs code that I've written so far:
{code}
import java.io.*;
import java.util.*;
import java.text.*;
public class Project {
     private static String nameSurname = "";     
     private static String num1 = null;
     private static String num2 = null;
     private static String choice1 = null;
     private static double answer = 0;
     private static String more;
     public double Add() {
          answer = (Double.parseDouble(num1) + Double.parseDouble(num2));
          return answer;
     public double Subtract() {
          answer = (Double.parseDouble(num1) - Double.parseDouble(num2));
          return answer;
     public double Multiply() {
          answer = (Double.parseDouble(num1) * Double.parseDouble(num2));
          return answer;
     public double Divide() {
          answer = (Double.parseDouble(num1) / Double.parseDouble(num2));
          return answer;
     public double Modulus() {
          answer = (Double.parseDouble(num1) % Double.parseDouble(num2));
          return answer;
     public double maximumValue() {
          answer = (Math.max(Double.parseDouble(num1), Double.parseDouble(num2)));
          return answer;
     public double minimumValue() {
          answer = (Math.min(Double.parseDouble(num1), Double.parseDouble(num2)));
          return answer;
     public double absoluteNumber1() {
          answer = (Math.abs(Double.parseDouble(num1)));
          return answer;
     public double absoluteNumber2() {
          answer = (Math.abs(Double.parseDouble(num2)));
          return answer;
     public double Squareroot1() {
          answer = (Math.sqrt(Double.parseDouble(num1)));
          return answer;
     public double Squareroot2() {
          answer = (Math.sqrt(Double.parseDouble(num2)));
          return answer;
     public static String octalEquivalent1() {
          int iNum1 = Integer.parseInt(num1);
String octal1 = Integer.toOctalString(iNum1);
return octal1;
     public static String octalEquivalent2() {
          int iNum2 = Integer.parseInt(num2);
          String octal2 = Integer.toOctalString(iNum2);
          return octal2;
     public static String hexadecimalEquivalent1() {
          int iNum1 = Integer.parseInt(num1);
          String hex1 = Integer.toHexString(iNum1);
          return hex1;
     public static String hexadecimalEquivalent2() {
          int iNum2 = Integer.parseInt(num2);
          String hex2 = Integer.toHexString(iNum2);
          return hex2;
     public double Round1() {
          answer = Math.round(Double.parseDouble(num1));
          return answer;
     public double Round2() {
          answer = Math.round(Double.parseDouble(num2));
          return answer;
          SimpleDateFormat format1 = new SimpleDateFormat("EEEE, dd MMMM yyyy");
     Date now = new Date();
     SimpleDateFormat format2 = new SimpleDateFormat("hh:mm a");
     static Date timeIn = new Date();
     public static long programRuntime() {
          Date timeInD = timeIn;
          long timeOutD = System.currentTimeMillis();
          long msec = timeOutD - timeInD.getTime();
          float timeHours = msec / 1000;
               return (long) timeHours;
     DecimalFormat decimals = new DecimalFormat("#0.00");
     public String insertNameAndSurname() throws IOException{
          boolean inputCorrect = false;
               while (inputCorrect == false) {
                    while (nameSurname == null || nameSurname.length() == 0) {
                         for (int i = 0; i < nameSurname.length(); i++) {
                         if ((nameSurname.charAt(i) > 'a') && (nameSurname.charAt(i) < 'Z')){
                                   inputCorrect = true;
                    else{
                    inputCorrect = false;
                    break;
                    try {
                         BufferedReader inStream = new BufferedReader (new InputStreamReader(System.in));
                         System.out.print("Please enter your name and surname: ");
                         nameSurname = inStream.readLine();
                         inputCorrect = true;
                    }catch (IOException ex) {
                         System.out.println("You did not enter your name and surname, " + nameSurname + " is not a name, please enter your name and surname :");
                         inputCorrect = false;
                    System.out.println("\nA warm welcome " + nameSurname + " ,todays date is: " + format1.format(now));
                    System.out.println("and the time is now exactly " + format2.format(timeIn) + ".");
                    return nameSurname;
          public String inputNumber1() throws IOException {
          boolean inputCorrect = false;
               while (inputCorrect == false) {
                    try {
                         BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
                         System.out.print("\nPlease enter a number you want to do a calculation with and hit <ENTER>: ");
                         num1 = br.readLine();
                         double number1 = Double.parseDouble(num1);
                         System.out.println("\nThe number you have entered is: " + number1);
                         inputCorrect = true;
                    } catch (NumberFormatException nfe) {
                         System.out.println("\nYou did not enter a valid number: " + "\""+ num1 + "\" is not a number!!");
                         inputCorrect = false;
                    return num1;
     public String calculatorChoice() throws IOException {
          System.out.println("Please select an option of what you would like to do with this number from the menu below and hit <ENTER>: ");
          System.out.println("\n*********************************************");
          System.out.println("---------------------------------------------");
          System.out.println("Please select an option from the list below: ");
          System.out.println("---------------------------------------------");
          System.out.println("1 - Add");
          System.out.println("2 - Subtract");
          System.out.println("3 - Multiply");
          System.out.println("4 - Divide (remainder included)");
          System.out.println("5 - Maximum and minimum value of two numbers");
          System.out.println("6 - Squareroot");
          System.out.println("7 - Absolute value of numbers");
          System.out.println("8 - Octal and Hexadecimal equivalent of numbers");
          System.out.println("9 - Round numbers");
          System.out.println("0 - Exit program");
          System.out.println("**********************************************");
          boolean inputCorrect = false;
               while (inputCorrect == false) {
                    try {
                         BufferedReader inStream = new BufferedReader (new InputStreamReader(System.in));
                         System.out.print("Please enter your option and hit <ENTER>: ");
                         choice1 = inStream.readLine();
                         int c1 = Integer.parseInt(choice1);
                         System.out.println("\nYou have entered choice number: " + c1);
                         inputCorrect = true;
                    } catch (NumberFormatException nfe) {
                         System.out.println("You did not enter a valid choice number: " + "\""+ choice1 + "\" is not in the list!!");
                         inputCorrect = false;
                    return choice1;
     public String inputNumber2() throws IOException {
          boolean inputCorrect = false;
               while (inputCorrect == false) {
                    try {
                         BufferedReader br2 = new BufferedReader (new InputStreamReader(System.in));
                         System.out.print("\nPlease enter another number you want to do the calculation with and hit <ENTER>: ");
                         num2 = br2.readLine();
                         double n2 = Double.parseDouble(num2);
                         System.out.println("\nThe second number you have entered is: " + n2);
                         System.out.println("\nYour numbers are: " + num1 + " and " + num2);
                         inputCorrect = true;
                    } catch (NumberFormatException nfe) {
                         System.out.println("You did not enter a valid number: " + "\""+ num2 + "\" is not a number!!");
                         inputCorrect = false;
                    return num2;
     public int Calculator() {
          int choice2 = (int) Double.parseDouble(choice1);
          switch (choice2) {
                    case 1 :
                         Add();
                         System.out.print("The answer of " + num1 + " + " + num2 + " is: " + decimals.format(answer));
                         break;
                    case 2 :
                         Subtract();
                         System.out.print("The answer of " + num1 + " - " + num2 + " is: " + decimals.format(answer));
                         break;
                    case 3 :
                         Multiply();
                         System.out.print("The answer of " + num1 + " * " + num2 + " is: " + decimals.format(answer));
                         break;
                    case 4 :
                         Divide();
                         System.out.print("The answer of " + num1 + " / " + num2 + " is: " + decimals.format(answer));
                         Modulus();
                         System.out.print(" and the remainder is " + decimals.format(answer));
                         break;
                    case 5 :
                         maximumValue();
                         System.out.println("The maximum number between the numbers " + num1 + " and " + num2 + " is: " + decimals.format(answer));
                         minimumValue();
                         System.out.println("The minimum number between the numbers " + num1 + " and " + num2 + " is: " + decimals.format(answer));
                         break;
                    case 6 :
                         Squareroot1();
                         System.out.println("The squareroot of value " + num1 + " is: " + decimals.format(answer));
                         Squareroot2();
                         System.out.println("The squareroot of value " + num2 + " is: " + decimals.format(answer));
                         break;
                    case 7 :
                         absoluteNumber1();
                         System.out.println("The absolute number of " + num1 + " is: " + decimals.format(answer));
                         absoluteNumber2();
                         System.out.println("The absolute number of " + num2 + " is: " + decimals.format(answer));
                         break;
                    case 8 :
                         octalEquivalent1();
                         System.out.println("The octal equivalent of " + num1 + " is: " + octalEquivalent1());
                         octalEquivalent2();
                         System.out.println("The octal equivalent of " + num2 + " is: " + octalEquivalent2());
                         hexadecimalEquivalent1();
                         System.out.println("\nThe hexadecimal equivalent of " + num1 + " is: " + hexadecimalEquivalent1());
                         hexadecimalEquivalent2();
                         System.out.println("The hexadecimal equivalent of " + num2 + " is: " + hexadecimalEquivalent2());
                         break;
                    case 9 :
                         Round1();
                         System.out.println("The rounded number of " + num1 + " is: " + decimals.format(answer));
                         Round2();
                         System.out.println("The rounded number of " + num2 + " is: " + decimals.format(answer));
                         break;
                    case 0 :
                         if (choice2 == 0) {
                              System.exit(1);
                         break;
               return choice2;
          public String anotherCalculation() throws IOException {
               boolean inputCorrect = false;
               while (inputCorrect == false) {
                         try {                              
                              BufferedReader br3 = new BufferedReader (new InputStreamReader(System.in));
                              System.out.print("\nWould you like to do another calculation? Y/N ");
                              more = br3.readLine();
                              String s1 = "y";
                              String s2 = "Y";
                              if (more.equals(s1) || more.equals(s2)) {
                                   inputCorrect = true;
                                   while (inputCorrect = true){
                                        inputNumber1();
                                        System.out.println("");
                                        calculatorChoice();
                                        System.out.println("");
                                        inputNumber2();
                                        System.out.println("");
                                        Calculator();
                                        System.out.println("");
                                        anotherCalculation();
                                        System.out.println("");
                                        inputCorrect = true;
                              } else {
                                   System.out.println("\n" + nameSurname + " thank you for using this program, you have used this program for: " + decimals.format(programRuntime()) + " seconds");
                                   System.out.println("the program will now exit, Goodbye.");
                                   System.exit(0);
                         } catch (IOException ex){
                              System.out.println("You did not enter a valid answer: " + "\""+ more + "\" is not in the list!!");
                              inputCorrect = false;
          return more;
     public static void main(String[] args) throws IOException {
          Project p1 = new Project();
          p1.insertNameAndSurname();
          System.out.println("");
          p1.inputNumber1();
          System.out.println("");
          p1.calculatorChoice();
          System.out.println("");
          p1.inputNumber2();
          System.out.println("");
          p1.Calculator();
               System.out.println("");
               p1.anotherCalculation();
               System.out.println("");
{code}
*Can you please run my code for yourself and have a look at how this program is constructed*
*and give me ANY feedback on how I can better this code(program) or if I've done anything wrong from your point of view.*
Your help will be much appreciated.
Thanks in advance

Smirre wrote:
Now my question is this: How can I restrict the user to only enter 'letters' (and spaces of course) but allow NO numbers for his/her surname??You cannot restrict the user. It is a sad fact in programming that the worst bug always sits in front of the Computer.
What you could do is checking the input string for numbers. If it contains numbers, just reprompt for the Name.
AND you might want to ask yourself why the heck a calculator needs to know the users Name.

Similar Messages

  • I need help with exporting project for the web

    Probably something i am doing wron g but here are the problems. When I use Quicktime Converter, if I try to convert to a Quicktime movie or an MPEG-4 nothing happens and i get a 'File error;File Unknown message' when i try to convert to an AVI File, it works, but even though I have already rendered the project, it shows up with little flashes of blue that say 'unrendered'. and finally, when I try to make it a w
    Windows Media File, it stops after 29 seconds. Any ideas?
    I have an iMac with dual core processor, and FCE HD 3.5.1. I have my video files on an external drive.
    iMac   Mac OS X (10.4.10)  

    perform a search using the term export for web and it should throw up some ideas.
    here's one for starters:
    http://discussions.apple.com/thread.jspa?messageID=2309121&#2309121
    If you're using flip4mac to convert to wmv, the trial stops at 30 seconds - you need at least wmvstudio to export to wmv:
    http://www.flip4mac.com/wmv.htm

  • I still need help with the Dictionary for my Nokia...

    I still need help with the Dictionary for my Nokia 6680...
    Here's the error message I get when trying to open dictionary...
    "Dictionary word information missing. Install word database."
    Can someone please provide me a link the where I could download this dictionary for free?
    Thanks!
    DON'T HIT KIDS... THEY HAVE GUNS NOW.

    oops, im sorry, i didnt realised i've already submitted it
    DON'T HIT KIDS... THEY HAVE GUNS NOW.

  • Need help in Creating classes for my assignment

    Hi ,
    I just started learning Java and have the following requirement
    1)     Create the following classes/interfaces using descriptions:
    a)     Account � data members : id:String, type:String, balance:BigDecimal, methods : Account, Account with String parameter, getId, getType, getBalance, setId, setType, setBalance, deposit, withdraw, compareTo, toString
    b)     Bank � data members: instance:Bank, accountsMap:Map, customersMap:Map, customersAccount:Map, transactionMap:Map, methods: getAccountsMap, getCustormersMap, getCustomersAccounts, getTransactionMap, associate, addTransaction, getAccount, getCustomer, getAccounts, getTransactions, deposit, withdraw, transfer
    c)     AccountDoesNotExistException, BankException, CustomerDoesNotExistException, InsufficientFundsException, InvalidAmountException, ZeroAmountException
    2)     Create the util package using the following class
    a)     AmountConverter � methods: fromDecimal(BigDecim     al), fromString(String)
    In 1 b how to Create Instance:bank in the class .Also how to do part2.If possible can you help me with all the parts.Based on these I've some more to do.

    Here is what I've come with
    ACCOUNT.JAVA
    import java.math.*;
    public class Account {
    private String Id;
    private String Type;
    private BigDecimal balance;
    public Account( ) {
    public Account(String Id,String Type,BigInteger balance) {
    this.Id = Id;
    this.Type = Type;
    this.balance = balance;
    public String getId( ) {
    return Id;
    public void setId(String Id) {
    this.Id = Id;
    public String getType( ) {
    return Type;
    public void setType(String Title) {
    this.Title = Type;
    public String getBalance( ) {
    return id;
    public void setBalance(String balance) {
    this.balance = balance;
    public String withdraw( ) {
    public String deposit( ) {
    public void setLastName(String LastName) {
    this.id = id;
    CUSTOMER.JAVA
    public class Customer {
    private String Id;
    private String Title;
    private String firstName;
    private String lastName;
    /** Construct a Customer with no data -- must be a no-argument */
    public Customer( ) {
    /** Construct a Customer with String Parameter */
    public Customer(String Id,String Title,String firstName,String lastName) {
    this.Id = Id;
    this.Title = Title;
    this.firstName = firstName;
    this.lastName = lastName;
    /** Return the Id. */
    public String getId( ) {
    return Id;
    /** Set the Id */
    public void setId(String Id) {
    this.Id = Id;
    /** Return the Title */
    public String getTitle( ) {
    return Title;
    /** Set the Title */
    public void setTitle(String Title) {
    this.Title = Title;
    /** Return the Firstname. */
    public String getFirstName( ) {
    return id;
    /** Set the Firstname. */
    public void setFirstName(String FirstName) {
    this.id = id;
    /** Return the Lastname. */
    public String getLastName( ) {
    return LastName;
    /** Set the Lastname. */
    public void setLastName(String LastName) {
    this.id = id;
    TRANSRECORD.JAVA
    import java.util.*;
    import java.math.*;
    public class TransRecord implements Comparable{
    private Date timeStamp;
    private String transType;
    private BigDecimal transAmt;
    /** Construct a Trans Record with no data -- must be a no-argument */
    public TransRecord( ) {
    /** Construct a Customer with String Parameter */
    public Customer(String transType,String transAmt) {
    this.transType = transType;
    this.transAmt = transAmt;
    /** Return the timeStamp. */
    public String gettimeStamp( ) {
    return timeStamp;
    /** Set the timeStamp */
    public void settimeStamp(Date timeStamp) {
    this.timeStamp = timeStamp;
    /** Return the TransType */
    public String getTransType( ) {
    return TransType;
    /** Set the TransType */
    public void setTransType(String TransType) {
    this.TransType = TransType;
    /** Return the TransAmt */
    public String getTransAmt( ) {
    return TransAmt;
    /** Set the TransAmt */
    public void setTransAmt(String TransAmt) {
    this.TransAmt = TransAmt;
    /** Return a String representation. */
    public String toString( ) {
    /** CompareTo method */
    public int compareTo(Object argument)
    ===============
    ACCOUNTDOESNOTEXISTEXCEPTION.JAVA
    public class AccountDoesNotExistException
                   extends Exception
         public AccountDoesNotExistException()
              super();
         public AccountDoesNotExistException(String message)
              super(message);
    =================
    BANKEXCEPTION.JAVA
    public class BankException
                   extends Exception
         public BankException()
              super();
         public BankException(String message)
              super(message);
    CUSTOMERDOESNOTEXISTEXCEPTION.JAVA
    public class CustomerDoesNotExistException
                   extends Exception
         public CustomerDoesNotExistException()
              super();
         public CustomerDoesNotExistException(String message)
              super(message);
    ACCOUNTDOESNOTEXISTEXCEPTION.JAVA
    public class AccountDoesNotExistException
                   extends Exception
         public AccountDoesNotExistException()
              super();
         public AccountDoesNotExistException(String message)
              super(message);
    INSUFFICIENTFUNDSEXCEPTION.JAVA
    public class InsufficientFundsException
                   extends Exception
         public InsufficientFundsException()
              super();
         public InsufficientFundsException(String message)
              super(message);
    INVALIDAMOUNTEXCEPTION.JAVA
    public class InvalidAmountException
                   extends Exception
         public InvalidAmountException()
              super();
         public InvalidAmountException(String message)
              super(message);
    ZEROAMOUNTEXCEPTION.JAVA
    public class ZeroAmountException
                   extends Exception
         public ZeroAmountException()
              super();
         public ZeroAmountException(String message)
              super(message);
    I need help with Bank Class and the util class.Correct me If I've missed any exceptions or if any syntax is wrong
    THanks
    AKsh

  • Help with a project for school

    This is the code that I came up with. The assignment for school said to edit the code I came up with for a program that will tell you the total pay with regular hours and overtime hours combined. Now we have to edit it using methods. I tried my best for the last 4 hours or so trying to figure this out but I need help because I can't figure this out. There is an error in the General Output that says "java.lang.NoClassDefFoundError: MethodsOne
    Exception in thread "main"
    Process completed." I cant figure out how to get rid of that. Other than that I cant seem to get it to do anything else that I would like it to do, like the actual calculations to get the final answer. Any helpful input on how to fix it would be awesome! Thanks!
    import TerminalIO.*;
    public class MethodsOne {
         private static String emp;
         private static double rate;
         private static int hours;
         private static int overtime;
         private static double overtimehours;
    public static void main(String Args[])
         stateEmpId();
           stateRate();
           calcHours();
           calcOvertime();
           calcOvertimeHours();
           calcEntirePay();     
         public static void stateEmpId()
              System.out.print ("Enter Employee ID: ");
              emp = reader.readLine();
           public static Void stateRate()
              System.out.print ("Enter Employee Hourly Wage: ");
              rate = reader.readDouble();
         public static Void calcHours()
              System.out.print ("Enter Employee Weekly Hours: ");
              hours = reader.readInt();
         public static void calcOvertime()
              System.out.print ("Enter Employee Overtime Hours: ");
              overtime = reader.readInt();
         public static void calcOvertimehours()
              overtimehours = ((1.5 * calcOvertime + CalcHours) * (StateRate));
         public static void calcEntirePay()
         System.out.println ("Your Total Pay for the week is:$ ");
         System.out.print (overtimehours);
    }Edited by: AndyB5073 on Nov 10, 2007 2:51 PM

    hi, sorry for my english. I�m change your source because you have problem to read to standar input (console). I wrote coments. bye good luck
    import java.io.IOException;
    public class MethodsOne {
         private static String emp;
         private static double rate;
         private static double hours;
         private static double overtime;
         private static double overtimehours;
    public static String inputRead() {
         byte buff[] = new byte[80]; // length line console
         try {
              System.in.read(buff,0,80);
         } catch (IOException e) {
              System.out.print ("input text length highest 80 ");
              // TODO Auto-generated catch block
              e.printStackTrace();
         return new String(buff);
    public static void main(String args[])
         stateEmpId();
           stateRate();
           calcHours();
           calcOvertime();
           calcOvertimeHours();
           calcEntirePay();     
         public static void stateEmpId()
              System.out.println ("Enter Employee ID: ");
              emp = inputRead();
           public static  void stateRate()
              System.out.println ("Enter Employee Hourly Wage: ");
              String tmp = inputRead();
              rate = Double.parseDouble(tmp);
         public static void calcHours()
              System.out.println ("Enter Employee Weekly Hours: ");
              String tmp = inputRead();
              hours = Double.parseDouble(tmp);
         public static void calcOvertime()
              System.out.println ("Enter Employee Overtime Hours: ");
              String tmp = inputRead();
              overtime = Double.parseDouble(tmp);
         public static void calcOvertimeHours()
              // overtimehours = ((1.5 * calcOvertime + CalcHours)* (StateRate));
              // bad --- dont use this methods: They are called in the main. Uses local variable
              overtimehours = ((1.5 * overtime + hours)* rate);
              // good --- using local variables
         public static void calcEntirePay()
         System.out.println ("Your Total Pay for the week is:$ ");
         System.out.print (overtimehours);
    }

  • Need help with Java app for user input 5 numbers, remove dups, etc.

    I'm new to Java (only a few weeks under my belt) and struggling with an application. The project is to write an app that inputs 5 numbers between 10 and 100, not allowing duplicates, and displaying each correct number entered, using the smallest possible array to solve the problem. Output example:
    Please enter a number: 45
    Number stored.
    45
    Please enter a number: 54
    Number stored.
    45 54
    Please enter a number: 33
    Number stored.
    45 54 33
    etc.
    I've been working on this project for days, re-read the book chapter multiple times (unfortunately, the book doesn't have this type of problem as an example to steer you in the relatively general direction) and am proud that I've gotten this far. My problems are 1) I can only get one item number to input rather than a running list of the 5 values, 2) I can't figure out how to check for duplicate numbers. Any help is appreciated.
    My code is as follows:
    import java.util.Scanner; // program uses class Scanner
    public class Array
         public static void main( String args[] )
          // create Scanner to obtain input from command window
              Scanner input = new Scanner( System.in);
          // declare variables
             int array[] = new int[ 5 ]; // declare array named array
             int inputNumbers = 0; // numbers entered
          while( inputNumbers < array.length )
              // prompt for user to input a number
                System.out.print( "Please enter a number: " );
                      int numberInput = input.nextInt();
              // validate the input
                 if (numberInput >=10 && numberInput <=100)
                       System.out.println("Number stored.");
                     else
                       System.out.println("Invalid number.  Please enter a number within range.");
              // checks to see if this number already exists
                    boolean number = false;
              // display array values
              for ( int counter = 0; counter < array.length; counter++ )
                 array[ counter ] = numberInput;
              // display array values
                 System.out.printf( "%d\n", array[ inputNumbers ] );
                   // increment number of entered numbers
                inputNumbers++;
    } // end close Array

    Yikes, there is a much better way to go about this that is probably within what you have already learned, but since you are a student and this is how you started, let's just concentrate on fixing what you got.
    First, as already noted by another poster, your formatting is really bad. Formatting is really important because it makes the code much more readable for you and anyone who comes along to help you or use your code. And I second that posters comment that brackets should always be used, especially for beginner programmers. Unfortunately beginner programmers often get stuck thinking that less lines of code equals better program, this is not true; even though better programmers often use far less lines of code.
                             // validate the input
       if (numberInput >=10 && numberInput <=100)
              System.out.println("Number stored.");
      else
                   System.out.println("Invalid number.  Please enter a number within range."); Note the above as you have it.
                         // validate the input
                         if (numberInput >=10 && numberInput <=100)
                              System.out.println("Number stored.");
                         else
                              System.out.println("Invalid number.  Please enter a number within range."); Note how much more readable just correct indentation makes.
                         // validate the input
                         if (numberInput >=10 && numberInput <=100) {
                              System.out.println("Number stored.");
                         else {
                              System.out.println("Invalid number.  Please enter a number within range.");
                         } Note how it should be coded for a beginner coder.
    Now that it is readable, exam your code and think about what you are doing here. Do you really want to print "Number Stored" before you checked to ensure it is not a dupe? That could lead to some really confused and frustrated users, and since the main user of your program will be your teacher, that could be unhealthy for your GPA.
    Since I am not here to do your homework for you, I will just give you some advice, you only need one if statement to do this correctly, you must drop the else and fix the if. I tell you this, because as a former educator i know the first thing running through beginners minds in this situation is to just make the if statement empty, but this is a big no no and even if you do trick it into working your teacher will not be fooled nor impressed and again your GPA will suffer.
    As for the rest, you do need a for loop inside your while loop, but not where or how you have it. Inside the while loop the for loop should be used for checking for dupes, not for overwriting every entry in the array as you currently have it set up to do. And certainly not for printing every element of the array each time a new element is added as your comments lead me to suspect you were trying to do, that would get real annoying really fast again resulting in abuse of your GPA. Printing the array should be in its own for loop after the while loop, or even better in its own method.
    As for how to check for dupes, well, you obviously at least somewhat understand loops and if statements, thus you have all the tools needed, so where is the problem?
    JSG

  • Need help with calculated fields in Adobe Interactive Forms

    Hi Gurus,
    I have an Adobe Interactive form in which i have radio buttons. Upon selecting any of the radio buttons, value in text box should be changed( Calculqated filedS). How i can achieve this?
    Regards,
    Srini
    Moderator message: wrong forum, please post again in Adobe Interactive Forms, but always try yourself before asking.
    Edited by: Thomas Zloch on Jul 13, 2010 11:58 AM

    Hi Tapan
    No, it's working ,with  one remark.
    I've done a mistake, in the final formula. The logic remain the same! ;)
     The calculation values for second column ( COL2 ) are 1,2,3 and not 0,1,2 as I wrote  before and as for COL1 are so the formula is
    =3*if(COL1="ABC",0,IF(COL1="DEF",1,2)+if(COL2="RST",1,IF(COL2="YYZ",2,3)
    and not
    =3*if(COL1="ABC",0,IF(COL1="DEF",1,2)+if(COL2="RST",0,IF(COL2="YYZ",1,2)
    I created also a real example  for you, with 2 dif calculation ways . First I created 2 calc_columns for COL1 and COL2 ( CALC_COL1+CALC_COL and after I added both these 2 column , and second way is to calculate directly) .
    Check this image
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

  • Need help with a project

    Hi,
    I'm a final year engineering student doing my project on cloud computing. Our project is a web application developed which concerns the issue of cloud security.Our lecturers asked us to put it on the cloud instead of showing it as a web application. So we
    are trying the trial version of Windows Azure. I need help in putting my project on to the cloud. Please help regarding this as soon as possible... 
    We are using Apache tomcat, JDK 1.6, Wamp server for our web application and we have developed this using netbeans IDE
    Very Urgent!!!

    Hello there, if you're still looking for help you might not be in the right forum.  This fourm is all about Azure SQL Database.

  • Need help with SQL retrieval for previous month till current date

    Hi ,
    Need help generating statistics from previous month from date of enquiry till current date of enquiry.
    and have to display it according to date.
    Date of enquiry : 03/02/2012
    Application Type| 01/01/2012 | 02/01/2012 | 03/01/2012 |...... | 31/01/2012 | 01/02/2012 | 02/02/2012 | 03/02/2012 |
    sample1 20 30 40
    sample 2 40 40 50
    sample 3 50 30 30
    Hope you guys can help me with this.
    Regards

    Hi,
    932472 wrote:
    Scenario
    1)If i run the query at 12 pm on 03/2/2012. the result i will have to display till the current day.
    2)displaying the count of the application made based on the date.
    Application type 01012012 | 02012012 | 03012012 | ..... 01022012| 02022012|03022012
    sample 1 30 40 50 44 30
    sample 2 35 45 55
    sample 3 36 45 55Explain how you get those results from the sample data you posted.
    It would help a lot if you posted the results in \ tags, as described in the forum FAQ. {message{id=9360002}
    SELECT     application_type as Application_type
    ,     COUNT (CASE WHEN created_dt = sysdate-3 THEN 1 END)     AS 01012012 (should be getting dynamically)
    ,     COUNT (CASE WHEN created_dt = sysdate-4 THEN 1 END)     AS 02022012
    ,     COUNT (CASE WHEN created_dt = sysdate-5 THEN 1 END)     AS 03022012
    , COUNT (CASE WHEN created_dt = sysdate-6 THEN 1 END)     AS 04022012
    FROM     table_1
    GROUP BY application_type
    ORDER BY     application_typeThat's the bais idea.
    You can simplify it a little by factoring out the date differences:WITH got_d     AS
         SELECT     qty
         ,     TRUNC ( dt
              - ADD_MONTHS ( TRUNC (SYSDATE, 'MON')
                        , -1
              ) AS d
         FROM table1
         WHERE     dt     >= ADD_MONTHS ( TRUNC (SYSDATE, 'MON')
                        , -1
         AND dt     < TRUNC (SYSDATE) + 1
    SELECT     SUM (CASE WHEN d = 1 THEN qty END)     AS day_1
    ,     SUM (CASE WHEN d = 2 THEN qty END)     AS day_2
    ,     SUM (CASE WHEN d = 62 THEN qty END)     AS day_62
    FROM     got_d
    See the links I mentioned earlier for getting exactly the right number of columns, and dynamic column aliases.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Need help with correction inscript for duplication on regular basis

    Hi,
    I am using Oracle 10.2.0.4 on Win 2008 R2. We have Archive mode enabled and no rman catalog is used. I have a requirement where i have to duplicate prod sevrer on regular basis to development server.
    I have created few batch files so that the entire process in automated. Stored all the scripts in c:\script\clone\ directory.+
    I have taken the backup copy of password and spfile from prod server and copied to the development server in same location.
    These are the scripts i run in order:
    *1_clone.bat*
    set ORACLE_SID=orcl
    sqlplus / as sysdba @c:\script\clone\2_test.bat
    *2_test.bat*
    shutdown immediate
    startup nomount
    host rman target sys/oracle@live nocatalog auxiliary / @c:\script\clone\3_rman.rcv
    *3_rman.rcv*
    run {
    allocate auxiliary channel d1 type disk;
    duplicate target database to ORCL NOFILENAMECHECK;
    exit
    When the duplication process in about to finish, i get below error:
    contents of memory script:
    shutdown clone;
    startup clone nomount;
    executing Memory Script
    RMAN-03002: failure of duplicate DB command at 07/31/2012 08:02:21
    RMAN-03015: error occured in stored script memory script
    RMAN-06136: Oracle error from auxiliary database: ORA-01013: user requested cancel of current operation
    Recovery Manager complete
    SQL>
    When i press exit, this window closes and i can run the alter database open resetlogs;+ command from a new sql prompt. I check online and some suggest there might be a window open with system user connected. Please suggest any changes in the script.
    Best Regards,

    Hello;
    Having another session with system user will cause rman to throw this error. For example another session used to start up database in nomount mode still being active.
    Duriing the cloning process the rman session needs to be exclusively connected to the auxiliary instance (no other session are allowed).
    Duplicate post
    request for help with rman cloning script
    Best Regards
    mseberg
    Edited by: mseberg on Jul 31, 2012 5:02 AM

  • Not exactly iweb - need help with a graphic for my site

    This doesn't fit anywhere so dumping it here. I drew by hand a graphic I want to use with iweb to put on my site as my site's logo. Main problem is that getting the background transparent isn't working well as when it was scanned the scanner didn't back the background "pure" white. I have tried adjusting the whitepoint and setting the color depth down, but still no good. I don't know a ton about graphic program use. I have an older copy of graphic converter that came on this powerbook when i got it. I would be fine having the graphic loose the marker look and have solid fill colors - just I am not good enough with computer drawing tools to do it on the computer! So I either need to get a volunteer to help me out, or some help with some detailed instructions to get this to work out... (also I am broke so no cost/shareware is only option here)
    many thanks!!!!
    I can get you a scanned jpg of the pic if needed.

    THANK YOU/___sbsstatic___/migration-images/migration-img-not-avail.png so the tolerance makes it not care so much about the gradations in color? what else is tolerence good for?
    I have a cleaner copy now after someone suggested GIMP, so played with it last night - though couldn't figure out transparency - that was clear on converter- just not cooperative till these wonderful directions.
    So now I know how to do it without messing with the pic, and with messing with it - both good lessons and got a bit brighter color out of the deal.
    many thanks for the straightforward and clear directions, they worked perfectly/___sbsstatic___/migration-images/migration-img-not-avail.png extra strars for you/___sbsstatic___/migration-images/migration-img-not-avail.png

  • Collage Students need help with Java project(Email Server) whats analysis?

    Hi im studying in collage at the moment and i have just started learning java this semester, the thing is my teacher just told us to do an project in java , since we just started the course and i dont have any prior knowledge about java i was wondering if some one could help me with the project.
    i choose Email Sevice as my project and we have to submit an analysis and design document , but how the hell am i suppose to know what analysis is ? i just know we use ER diagrams & DFD's in the design phase but i dont know what analysis means ?
    could some one tell me what analysis on an email service might be? and what analysis on a subject means? is it the codeing involved or some thing coz the teacher told us not to do any codeing yet so im completly stumped,
    oh and btw we are a group of 3 students who are asking u the help here coz all of us in our class are stupmed ?

    IN case any one is interested this is the analysis i wrote
    ANALYSIS
    Analysis means figuring out what the problem is, maybe what kinds of solutions might be appropriate
    1.     Introduction:-
    The very definition of analysis is an investigation of the component parts of a whole and their relations in making up the whole. The Analysis done here is for an emailing service called Flashmail, the emailing service is used to send out mails to users registered with our service, these users and there log activities will be stored in some where, the most desirable option at this time is a Database, but this can change as the scope of the project changes.
    2.     Customer Analysis:-
    We are targeting only 30 registered users at the moment but this is subject to change as the scale changes of the project .Each user is going to be entitled to 1MB of storage space at this time since we lack the desired infrastructure to maintain anything higher than 1MB but the end vision of the project is to sustain 1000 MB of storage space while maintaining a optimal bandwidth allocation to each user so as to ensure a high speed of activity and enjoyment for the Customer.
    The Service will empower the user to be able to send, read, reply, and forward emails to there specified locations. Since we are working on a limited budget we can�t not at this time enable the sending of attachments to emails, but that path is also left open by modularity of java language, so we can add that feature when necessary.
    3.     Processor Load Analysis:-
    The number of messages per unit time processing power will be determined on hand with various algorithms, since it is best not to waste processor power with liberally distributing messages per unit time. Hence the number of messages will vary with in proportion to the number of registered users online at any given time.
    4.     Database Decision Analysis:-
    The High level Requirements of the service will have to be decided upon, the details of which can be done when we are implementing the project itself. An example of high level requirements are database management, we have chosen not to opt for flat files because of a number of reasons, first off a flat files are data files that contain records with no structured relationships additional knowledge is required to interpret these files such as the file format properties. The disadvantages associated with flat files are that they are not fast, they can only be read from top to bottom, and usually they have to be read all the way through. Though there is are advantages of Flat files they are that it takes up less space than a structured file. However, it requires the application to have knowledge of how the data is organized within the file.
    Good databases have key advantage over flat files concurrency. When you just read stuff from file it�s easy, but tries to synchronize multiple updates or writes into flat file from scripts that run in different process spaces.
    Whereas a flat file is a relatively simple database system in which each database is contained in a single table. In contrast, relational database systems can use multiple tables to store information, and each table can have a different record format.
    5.     Networking Analysis:-
    Virtually every email sent today is sent using two popular protocols known as SMTP (Simple Mail Transfer Protocol) and MIME (Multipurpose Internet Mail Extensions).
    1.     SMTP (Simple Mail Transfer Protocol)
    The SMTP protocol is the standard used by mail servers for sending and receiving email. In order to send email we will first establish a network connection to our SMTP server. Once you have finished sending your email message it is necessary that you disconnect from the SMTP server
    2.     MIME (Multipurpose Internet Mail Extensions)
    The MIME protocol is the standard used when composing email messages.

  • Need performance! - Need help with Server Architecture for SSAS on Azure VM

    I would like to build 100% Azure VM base solution. We can install as many as needed.
    I have large amount data in DW. (100GB-1000GB)
    I would like to provide PowerView reports in SharePoints.
    I would like to have report data be as real time as possible. (Min data is updated once in 2 hours)
    These are requirements:
    -SharePoint 2013
    -PowerView
    -SSAS OLAP Cube
    -SQL Server DW&Staging DB (Currently DW&Staging on same server)
    I need help specially what can be done with SSAS to meet requirements? Should be installed to own application server? Possible to install multiple SSAS? SSRS needs own server?
    I appreciate also links to server topology diagrams.
    Kenny_I

    I assume you mean 100GB-1000GB (not 1000TB) right?
    For Sharepoint I would refer to the sizing guide for diagrams and sizing:
    http://technet.microsoft.com/en-us/library/ff758647(v=office.15).aspx
    SSRS (and Power View) will run in the SharePoint farm on a SharePoint app server potentially with other SharePoint services.
    I would definitely put SSAS on a dedicated server for a cube that size. Depending on how well your data compresses, there may not be a VM in Azure with enough RAM to put your model into a Tabular SSAS model. I would prototype it with a subset of data to see
    how well it compresses. You can always use a Multidimensional model as a fallback.
    Depending on how much processing the SSAS model impacts user queries (since it is happening during the day) you could build an SSAS processing server and a separate SSAS query server and run the XMLA Synchronize command to copy the cube incrementally from processing
    to query servers.
    Does that help?
    http://artisconsulting.com/Blogs/GregGalloway

  • Need help with XI certif for technical consultant

    Hi XI experts ,
    I am trying for certif for Development Consultant SAP NetWeaver u201904 - Exchange Infrastructure & Integration Technology -  C_TBIT44_04 .
    Can somebody please give me some sample questions and answers?
    I really will appreciate such help since I donu2019t have any idea what kind of questions are at the exam!
    I only have heard it is not an easy exam to take.?Is this true?
    Also any shared experienced will be appreciate it. If you have, please give me more hands on information , not just course numbers and syllabus.
    Looking forward to receive info from you. Please use emal contcts in my Business Card.
    Thanks in advance all!
    Jim

    HI,
    Yes its true ...any SAP certification is never ever be the easy stuff...that could be easily achievable....
    You need to be well prepare for the Certification. There are many SDN links available for sample questions. you can just search on SDN as well as on Internet.
    https://www.sdn.sap.com/irj/sdn/developerareas/xi?rid=/webcontent/uuid/a680445e-0501-0010-1c94-a8c4a60619f8
    1. SAP XI Certification - Important Topics
    2. Regarding XI Certification Material.
    3. Xi sample Certification questions
    XI certification passing used to be normally 65%. It may vary based on the runtime exam rules.
    There are marks as well as no of questions allocated for every section, so you may refer below link
    you can go to the following site and check the information.
    https://service.sap.com/%7Esapidp/011000358700005902252004E
    https://service.sap.com/~sapidp/011000358700003595762004E
    SAP XI Certification - Important Topics All about XI certification
    Thanks
    Swarup

  • Need help with installing Windows for the bar exam

    I need to retake the bar exam in Feb 2011 and I've decided to switch to typing. I am trying to figure out what Windows I need (the software says XP is fine but is that even available anymore)- so can someone walk me through this process? I've partioned my hard drive with the default 5GB but should it be more?
    I'm looking at buying Windows- is XP okay or should I shell out for 7-i.e. is one more compatible with Macs?
    And then finally, in the installation instructions they mention that I need my Mac OS disc for the process- is that the snow leopard disc or something else? My discs are in storage right now so should I wait until I get them before starting this process or can I get replacements if I accidentally threw them out in moving?
    Sorry for all the questions, but well, I'm racing to get everything done and I want to make sure I don't crash my system halfway through the exam!

    You don't need Boot Camp, but even XP will have a lot of stuff to update from after the install, and that takes temp space. Just as your Mac shows 5-10GB there is add'l hidden space used.
    Apple's 'requirements' has gotten others in trouble and I was pretty sure it was more like 10GB. Plus a lot of XP discs are now SP3.
    XP out of the box but connected to the net is just waiting for malware, average is 15 minutes to be infected. 7 is better and just in case you need it again.
    System Builder can come in 32 or 64-bit but XP is 32-bit only.
    VirtualBox by Oracle is a free VM.
    1GB for one program actually seems like a lot, or is that RAM requirement?

Maybe you are looking for