Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
This is a question on my test and I was wondering if any of you experts would know how I could start something like this. Thank you for your time!
Write a shell script that uses a loop to build a table of Fahrenheit temperatures and the corresponding Celsius temperatures. The script must meet these requirements:
a. The script must ask the user for the starting Fahrenheit temperature, ending Fahrenheit temperature and increment.
b. To calculate the Celsius temperature use the formula °C = (°F - 32) x 5/9
c. The table should have the headings "Degrees F" and "Degrees C"
d. The left hand column of the table should contain Fahrenheit temperature; the right column should contain the corresponding Celsius temperature.
e. You do NOT need to check for an infinite loop. You can assume that the user will provide reasonable input.
This is a question on my test and I was wondering if any of you experts would know how I could start something like this. Thank you for your time!
Write a shell script that uses a loop to build a table of Fahrenheit temperatures and the corresponding Celsius temperatures. The script must meet these requirements:
a. The script must ask the user for the starting Fahrenheit temperature, ending Fahrenheit temperature and increment.
b. To calculate the Celsius temperature use the formula °C = (°F - 32) x 5/9
c. The table should have the headings "Degrees F" and "Degrees C"
d. The left hand column of the table should contain Fahrenheit temperature; the right column should contain the corresponding Celsius temperature.
e. You do NOT need to check for an infinite loop. You can assume that the user will provide reasonable input.
Yes; you can start by reading your textbook, looking at any of the many thousands of bash scripting guides you can find, and begin there. You need to read the LQ Rules and the "Question Guidelines" link. We're happy to help, but we aren't ever going to write scripts or do your homework for you.
That said, as hydrurga pointed out, writing things out in plain english often helps. Think about each step, and what it will take to accomplish it. For example:
a. "Ask the user" = prompt for user input and read it. Going to read three variables (start, end, and increment). Search for "how to read user input in bash scripting"
b. You have a formula, so you know how to perform math. Search for "how to perform math in bash scripting".
b1. You have a start/end range...this means you have to loop through all of them. Search for "how to loop within a bash script"
c. You have to print output. Search for "how to print bash script output to screen"
d. Same search as c
e. Nothing to do.
To the OP, it is not going to help your education in any way if we hand-feed you answers to your homework questions. You should at least put in some effort.
Wow, nice catch...
I am surprised that the slackoverflow suggestion keeps going with the while loop route as inputed values seems to fit better in a for loop. But I aggree with the possible perl or python use
I sense that you might be a by-product of that awful educational travesty called "No Child Left Behind™," which very-successfully sold the world on the notions that:
... the world consists of standardized tests, and
... you are entitled to succeed, and
... you can sue your teacher if you don't.
This week, I plan to use the money that I will earn from several decades of software experience to pay "a wizard with a backhoe" to fix my driveway, before I pay another expert to tackle a metal roof, and another to tackle a leaking chimney.
It so happens that, from my earliest childhood, "computers" were – and, still are(!) – a genuine (software-only ...) fascination for me. Therefore, I was – and, I still am – self-driven.
If(!) "this computer software thing" is seriously "what you are interested in doing," then ... do it, yourself!
... otherwise, "please pick something else to do, while there's still time."
Last edited by sundialsvcs; 03-19-2018 at 08:21 PM.
if i had time, i would do that. However i do not have the time...that's why i made a post here. Thanks for your not very helpful advice tho!
Getting someone to do your homework for you because you 'do not have the time' won't get you help. Your schedule and lack of planning doesn't make this an issue for us. Neither will your snotty comment about the 'not very helpful advice' get you far.
If you want to learn and show effort, you're in the right place. If you want a handout, go elsewhere.
Please stop posting your test and homework assignment questions, showing no effort. LQ is a friendly site, however not about doing work for you.
All members are volunteers and are willing to help, including with homework assignments. A stated guideline in the LQ Rules is that you do not post homework or test questions verbatim, with one reason being that your instructor may be a LQ member.
The other guidelines are that you need to show some effort with your assignments.
If you wish to solely ask for answers and receive them, then the LQ site is not for you.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.