473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do i write algorithms?

Write an algorithm that gets a numeric grade value 0 to 100 from the user, and produces the equivalent letter grade using the standard scale of 90-100 is A, 80-89 is B, 70-79 is C, 60-69 is D, and below 60 is F. The output should resemble:
The score entered was 85 and the letter grade is B
Compute and display the value x ÷ y if the value of y is not 0. If y does have the value 0, then display the message 'Unable to perform the division.'
Compute the volume and circumference of a cylinder given the length L and radius r if the radius is greater than or equal to 1.0; otherwise, your algorithm should compute only the circumference.
Write an algorithm that take three numbers and determines which number is the largest of the three and outputs something along the lines of:
The largest value of 10, 22, and 11 is 22
Sep 1 '10 #1
3 2448
wizardry
201 100+
the code below should give you an example of how to do the formulas for letter grades. the question is are u going to be creating pointers/virtual pointers or need to inherit their functions for more processing instead of re-writting the code? but for the cylinder this should give you an example as well on how to take the integers given and formulate them.

here is an example:

Expand|Select|Wrap|Line Numbers
  1. //Author Theo Werntz II
  2. //CIS 242
  3. //Date 07/21/04
  4. //Project L_2_P_1
  5.  
  6.  
  7. #include <iostream>
  8.  
  9. using std::cout;
  10. using std::cin;
  11. using std::endl;
  12.  
  13.  
  14.  
  15. // main functions
  16.  
  17.  
  18. int main()
  19. {
  20.    int total = 0;          // total feed
  21.    int feedA = 2.50;     // feedA
  22.    int feedB = 3.15;     // feedB
  23.  
  24.  
  25.  
  26.    cout << "Enter the letter of feed." << endl
  27.         << "The Feed List Is As." << endl
  28.     << "Feed A = $2.50 per 100 lbs."<< endl
  29.     << "Feed B = $3.15 per 100 lbs."<< endl
  30.     << "When Finished with Order Press."<<endl
  31.     <<    "CTRL Z to Calculate Total."<<endl;
  32.  
  33.  
  34.  
  35. //while loop for total
  36.  
  37.  
  38.    while ( ( total = cin.get() ) != EOF ) {   
  39.  
  40.  
  41. // determine which feed is input
  42.  
  43.  
  44.       switch ( total ) {      // nested switch structure in while
  45.  
  46.  
  47.          case 'A':            // feedA uppercase A
  48.          case 'a':            // or feedalowercase a
  49.             ++feedA;         // increment aCount
  50.             break;            // exit switch
  51.  
  52.  
  53.          case 'B':            // feedB uppercase B
  54.          case 'b':            // or feedb lowercase b
  55.             ++feedB;         // increment bCount    
  56.             break;            // exit switch
  57.  
  58.  
  59.          case '\n':           // ignore newlines,  
  60.          case '\t':           // tabs, 
  61.          case ' ':            // and spaces in input
  62.             break;            // exit switch
  63.  
  64.  
  65.          default:             // trap for anything except letter a 
  66.                             // and letter b.
  67.             cout << "Incorrect feed letter was entered."
  68.                  << " Enter a new feed letter." << endl;
  69.             break;            //exit switch 
  70.  
  71.  
  72.       }             // end switch
  73.  
  74.  
  75.    }                 // end while
  76.  
  77.    // output summary of feed
  78.  
  79.    cout << "\n\nTotals For each Feed Are:" 
  80.         << "\nA: " << feedA           // display number of A feed ordered
  81.         << "\nB: " << feedB           // display number of B feed ordered
  82.         << endl;
  83.  
  84.    return 0;              // indicate successful termination
  85.  
  86. }                 // end function main
  87.  
  88.  
  89.  
  90.  
Sep 1 '10 #2
donbock
2,426 Expert 2GB
The algorithm is the strategy you use to solve the problem. An algorithm can be expressed in text (like a cookbook recipe), graphically (like a flowchart), or in a computer language.
Sep 1 '10 #3
Oralloy
988 Expert 512MB
Don has the right of it.

An algorithm is simply an unambiguous statement of how to achieve a result.

The rest is implementation.

So, since we're not in the homework business, Avery, how about you take a stab at your three and tell us what your algorithms are. Then we can comment on them for you.

Cheers!
Sep 1 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Rob McLennan - ZETLAND | last post by:
Hi, I'm relatively clueless when it comes to correct ASP syntax. I'm testing out a search form for my company's website which is done in ASP. The results are displayed as per the code shown at the...
7
by: Carol | last post by:
I need to put this whole line into a response.write statement: field delimiter = "\"" how?
4
by: Richard Tierney | last post by:
To create help output (the response to "myprog --help", for example) I currently create a big .h file, which includes a single string, such as: static char *help_text = "\ myprog: my program\n\...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
4
by: Martin Feuersteiner | last post by:
Dear Group I'm new to http responses / requests and would be grateful if you can shed some light on this issue. Let's assume I've two pages, a.aspx and b.aspx. The buffer is set to false for...
6
by: J | last post by:
Kind of new at programming/vb.net. I'm doing this junky die roller program. Heres's what is supposed to happen: Roll 2 6-sided dies. Add rolls together put total in rolls(d6total). Display...
6
by: isaac2004 | last post by:
hello i am getting a type mismatch for a page i am trying to write. any help would be great source code <%@ Language=VBScript %> <% Option Explicit %> <!--#include...
4
by: Erland | last post by:
Hi , I am using Asp.net 1.1 using VB.NET and in the Page_Load() method I am trying to use a Response.Write method as following but I keep getting errors, --------------------------...
3
by: erictran | last post by:
Gday everyone, Please help me. How to read and write a pointer of character to a file? Thanks in advance. Eric
3
by: Simon Gare | last post by:
Hi All, having a problem with the error "Either BOF or EOF is True, or the current record has been deleted. " found a workaround that allows the non existent data to be bypassed and insert a 0...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.