• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Need help with a assignment (student)

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Guys I need help with the following I have a assignment due in a few days so far I've covered most of the work only this is outstanding if you could be so kind as to assist with the pseudocode and the java .

4.1 Write the pseudocode for a program in Java that converts an amount entered in dollars to the converted currency in Rands. The exchange rate of 1 dollar to the rand is 10.74.

4.2 Write the code for the plan in 4.1

 
lowercase baba
Posts: 13081
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for now, ignore 4.2. forget about java. Forget about computers.

how would YOU, personally, with pencil, paper, and eraser, convert a dollar amount into Rands?
 
Wahleed joshua
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would put together a sum like in maths and do a calculation.
 
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Wahleed joshua wrote:I would put together a sum like in maths and do a calculation.




Can you elaborate the maths a little bit? Of course, we are going to keep asking you to elaborate more and more -- until it looks like pseudo code...

Henry
 
Wahleed joshua
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no idea were to start I don't know pseudocode at all im in my first year and trying to learn informatics based on java.
 
Marshal
Posts: 27450
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your teacher hasn't discussed pseudocode in class? And your textbook doesn't have any examples of it?
 
Wahleed joshua
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what is in the textbook and example of pseudo code


1. Start
2. Ask user a question
3. Prompt user for an answer
4. IF the answer is correct, display the message “Congratulations!” ELSE display the message “Sorry, wrong answer. Please try again”
5. Stop
 
Greenhorn
Posts: 2
IntelliJ IDE MySQL Database Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Wahleed joshua wrote:This is what is in the textbook and example of pseudo code


1. Start
2. Ask user a question
3. Prompt user for an answer
4. IF the answer is correct, display the message “Congratulations!” ELSE display the message “Sorry, wrong answer. Please try again”
5. Stop



Here, in your case,

You can do it like:
1. Start
2. Take a value from user in dollar
3. "Elaborate your maths calculation"
4. Output a value in Rands
5. Stop

I would love to provide elaboration, but you can give this a try!
 
Wahleed joshua
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know if this is correct ?


1. Start
2. User input ?
3. Where 1 dollar is equals to 10.74 rands .
4. Output
5. Stop
 
Wahleed joshua
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See below?

1. Start
2. Take a value from user in dollar
3. "Where 1 dollar is equals to 10.74 rands
4. Output a value in Rands
5. Stop
 
Henry Wong
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Wahleed joshua wrote:I don't know if this is correct ?



Whether it is correct or not, to us, is not really relevant. Think of pseudo code as an English Description that you can work to get to real code. In other words, the more elaborate the pseudo code, the more easier it is to get to real code. Does that pseudo code work for you?

Wahleed joshua wrote:
3. "Where 1 dollar is equals to 10.74 rands



Let's say that the user enters X dollars, does that description help you understand how many Rands is that? Or can you elaborate it more, to make the description easier?

Henry
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Wahleed joshua wrote:See below?


Do you have children? Or a younger brother or niece?

If not, imagine that you do and that they're about 10 years old. How would you explain to them precisely how to convert Dollars to Rands?

Now write out those instructions in English (or your native language) in sequential form, and you'll have something approaching pseudo-code.

HIH

Winston
 
Marshal
Posts: 76817
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote: . . .Do you have children? Or a younger brother or niece? . . .

Grandparents, you mean
 
fred rosenberger
lowercase baba
Posts: 13081
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
pseudo-code is nothing more than writing out step-by-step instructions on how to do something. Usually, one would make several passes at re-writing and refining. For example, if the problem was "go to work", you might start with this:

1) get in car
2) drive to work
3) walk to desk

Hurray!!! I'm done!!!

wait, what? "drive to work" is a little vague and you don't know how do to that? Ok, i'll refine my steps:

1) get in car
2) start car
3) pull out of garage
4) turn left onto street.
5) make first left turn possible
6) turn left at first light
7) When you see office parking lot, turn into it and park
8) walk to desk

NOW i'm done...oh. You don't know how to star the car? ok...

1) get in car
2a) put key in ignition
2b) turn key, twisting it so top of key moves away from your body
2c) when the engine catches, release key
3) pull out of garage
4) turn left onto street.
5) make first left turn possible
6) turn left at first light
7) When you see office parking lot, turn into it and park
8) walk to desk

and you keep doing like this, refining each step into more and more explicit details. I would say your pseudo code would start with this:

1) get user input
2) convert dollars to rands
3) print output

 
Ranch Hand
Posts: 153
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is probably too late, but here are some tips:

1. Write a main function and keep running the code inside it until the user provides a right answer.
2. Print out the question
3. Use a variable that holds the user input
4. Write an if-else statement that checks for the right answer.
5. Escape the program when the user provides the right answer.
 
Campbell Ritchie
Marshal
Posts: 76817
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest the main() method (pedantic mode: it is not a function) should contain one statement, and the loop is probably better off in a different method. Possibly in a different class.
 
Yes, my master! Here is the tiny ad you asked for:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic