Jump to content
The Official Site of the Vancouver Canucks
Canucks Community

C# Programming Help


Zigmund.Palffy

Recommended Posts

Hey guys im having a little bit of trouble doing some C# coding right now and cant really finish this assignment just having a bit of trouble writing this code

heres the question:

A nutritionist who works for a fitness club helps memebers by evaluating their diets.As part of her evaluation, she asks members for the number of fat grams and carbohyrdrae grams that they consume in a day. Then, she calculates the number of calories that results from the fat using the following formula:

Calories from fat = fat grams x 9

Next, she calculates the number of calories that result from the carbohydrates using the following formula:

Calories from Carbs = Carbs grams x 4

Create an application that will make these calculations. In the application, you should have the following methods:

FATCALORIES - this method should accept a number of fat grams as an argument and return the number of calories from that amount of fat.

CARBCALORIES- this method should accept a number of carbohydrate grams as an argument and return the number of calories from that amount of carbohydrate.

Any help would be appreciated :(

Link to comment
Share on other sites

So you can set up a function that takes in a interger variable fatgrams and return the type double fat calories.

so something like. You should be able to look up the syntax of how to declare a function.

some ideas:

double fatcalories = fatgrams x9;

return fatcalories;

Link to comment
Share on other sites

Shouldn't you be actually trying to learn this?

Exactly what happened in his other post /topic/336236-c-programming-help/">http://forum.canucks...ogramming-help/, we essentially wrote and tested it for him. There was no reply, so I have no idea if it actually helped or was simply copied/pasted and handed in.

I don't mind helping at all but he needs to be more descriptive, give some context around what you are doing so we can help without doing it for you (and maybe keep it in the same thread).

Link to comment
Share on other sites

You should clarify why you can't get it done as it is not at all clear. You should be specific about what exactly is holding you back.

Also, are you actually interested in programming? Or is this course just a technicality? If you actually want to learn how to program, Its not going to help you in the slightest if you don't figure these things out for yourself. if you want to be a programmer you have to have a healthy sense of self determination and intellectual curiosity. So if that is your intention, then the kind of help you need isn't getting an assignment done, its understanding how to do it.

Link to comment
Share on other sites

shouldn't that be part of the description of the assignment?

If it doesn't say I imagine for both fat and carbs you would want in input box, and an output box. Buttons are somewhat optional as you should be able to detect when the input box changes.

Link to comment
Share on other sites

heres my programming so far ....


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace WindowsFormsApplication1

{

	public partial class Form1 : Form

	{

		public Form1()

		{

			InitializeComponent();

		}

		private int fatCalories ( int fat)

		{

			return fat * 9;

		}

		private int carbCalories (int carbs)

		{

			return carbs * 4;

		}

		private void calculateButton_Click(object sender, EventArgs e)

		{

			int fatCALORIES;

			int carbCALORIES;

		    int fat

		    int carbs


			if(int.Parse(fatTextbox.Text))

			{

				fatCALORIES = fat * 9;



		}

	}

}

i tried tryParse, and Parse it does not work , it says its an error :s

I dont know where to go from here ..

heres my form !

bada.png

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...