Jump to content

Who can show me how to do this program?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
Guest_Sharp_*

Guest_Sharp_*
  • Guests
I am so freaking lost. I am completely new to programming. I bought a java programming book to try and teach myself. This is one of the programs it asks you to make. It doesn't show you how to do it either. I have been able to do all the programs it has requested so far. I'm freakin stumped. It asks you to do this program without using the math operators. any help here would be greatly appreciated. Ill make it worth your time to respond. My e-mail is CastorTroy357@hotmail.com. thanks in advance to anyone that helps.

1)Prompt the user and accept a number from standard input.
2)Prompt the user and accept a symbol character from standard input. The symbol must be either an ^ or an !. If it is neither of these, display an error message and end the program.
3)If the symbol is a !, compute the factorial of the number entered in step 1 and display the result.
4) if the symbol is a ^, prompt the user to enter a second number, and then calculate the 1st number to the power of the 2nd number (similar to tonight's exercise). Display the result.
5) You must use iteration/loops for the factorial and exponent calculations

#2
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
hmm seems like H.W huh?

#3
Frantic

Frantic

    Learning Programmer

  • Members
  • PipPipPip
  • 91 posts
I'd say homework - not book work. This isn't a complex program - just read the chapter of the book. Should be fairly easy to learn and do within a couple of day.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Do you know how to compute factorials and integer powers?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
dirkfirst

dirkfirst

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 354 posts
Yup, homework. Why don't you post your code and then we can help you solve the problem?

#6
Lop

Lop

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,172 posts
Please post whatever you have and we will help you out as best we can.

#7
icepack

icepack

    Programmer

  • Members
  • PipPipPipPip
  • 115 posts
break the problem up into smaller problems. (hopefully the book you bought is using java 1.5)

1) and 2), look up how to accept import from the keyboard(hint: Scanner!)
2) in what way would you check(keyword: check) if it's a certain character? think what kind of statement that would use
3) and 4) simply develop seperate cases based on the results of the check.
like:
if( this is true) then do this
else if (that is true) then do that

5) is just telling you to use a loop to do your calculations, (and not recursively)

look in the java API for methods if your book doesn't lay them out.
http://java.sun.com/...1.5.0/docs/api/

that site can be your best friend sometimes.

and you won't learn much if you ask for all the code and have someone email it. you HAVE to be able to do it on your own, or else completing the exercise is worthless.

good luck!

#8
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
im pretty new to java but for an input box i woud do something like this...
UserInput = new javax.swing.JOptionPane().showInputDialog("Enter a value");

and since the input is a String use, you need to convert it to int inorder to perform mathamatical operations on it, so possable something like

x = Integer.parseInt( UserInput );

then just use a for loop to do the iterations

but i know very little regarding java so dont quote me