Hello!
I'm currently working on a program for class and I'm stuck. Here's the directions:

1.) Read one integer, n, from file: data.dat (the number "21" is in this file)
2.) The program (4 methods) will loop n times, using indexes 1 to n.
3.) Each time through the loop:
If the loop index is divisible by 3:
Call a function, three, that prints that number on a line
along with three "*" characters.
Pass the number to be printed as a pass-by-value parameter.

Else If the loop index is divisible by 5:
Call a function, five, that prints that number on a line with 5 "#" characters.
Pass the number to be printed as a pass-by-value parameter.

Else If the loop index is divisible by 3 AND by 5:
Call a function, both, that prints that number on a line n times.
Pass the number to be printed as a pass-by-value parameter.

Otherwise:
Print the number on the line.

Here's an example output:

1
2
3 ***
4
5 #####
6 ***
7
8
9 ***
10 #####
11
12 ***
13
14
15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
16

Here's what i have so far:

using System;
using System.IO;
class FIZZ
{

    static void Main()
    {
        int n;
        StreamReader reader;
        reader = new StreamReader("data.dat");
        n = Convert.ToInt32(reader.ReadLine());
    }

I'm lost as to how to create/call methods...I'm just completely lost in general. All help will be appreciated!

Here's a couple things that will help you:

for(int x = 1; x <= n;x++)
{

//print out number

   if(x%3==0)
   {
        //print out the ***
   }
   else if(x%5==0)
   {
      //print out the ##### 
   }
   else if(x%5==0 && x%3==0)
   {
          //make for loop that prints x, x number of times
   }
   
}

this is just to give you the basic idea you will have to adjust to what the assignment says but that is basically it.

I'm lost as to how to create/call methods...I'm just completely lost in general. All help will be appreciated!

Sounds like you need to get a good book and do some reading on OOP (Object Oriented Programming).

Here is a good website that will help you understand the principles of it. Your assignment is calling for you to use methods and pass parameters. Therefore in order to complete it, you are at least going to need to know the basics of OOP!

Check out this link:

http://www.astahost.com/info.php/Tutorial-Lesson-4-Object-Oriented-Programming_t15397.html

This article has been dead for over six months. Start a new discussion instead.