Jump to content

Welcome to canucks.com Vancouver Canucks homepage

Photo

C# Programming Help


This topic has been archived. This means that you cannot reply to this topic.
15 replies to this topic

#1 Zach Parise

Zach Parise

    Canucks First-Line

  • Members
  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 6,411 posts
  • Joined: 20-March 09

Posted 03 November 2012 - 08:19 PM

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 :(

#2 Rhinogator

Rhinogator

    Canucks Rookie

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,736 posts
  • Joined: 14-May 10

Posted 03 November 2012 - 09:12 PM

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;
Posted ImagePosted Image

#3 butters

butters

    Canucks Rookie

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,525 posts
  • Joined: 23-July 04

Posted 03 November 2012 - 10:18 PM

Well, for starters you could say what exactly you are having trouble with. The assignment is simple enough that no general help can be given without basically doing it for you.

#4 Zach Parise

Zach Parise

    Canucks First-Line

  • Members
  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 6,411 posts
  • Joined: 20-March 09

Posted 03 November 2012 - 11:06 PM

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;


yea i know that part..

Just that Do i make a textbox so that the user can input the number then calculate it ?

#5 Rhinogator

Rhinogator

    Canucks Rookie

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,736 posts
  • Joined: 14-May 10

Posted 03 November 2012 - 11:17 PM

yea i know that part..

Just that Do i make a textbox so that the user can input the number then calculate it ?


No, its asking you for a parameter, not user input.
Posted ImagePosted Image

#6 Zach Parise

Zach Parise

    Canucks First-Line

  • Members
  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 6,411 posts
  • Joined: 20-March 09

Posted 04 November 2012 - 01:45 PM

No, its asking you for a parameter, not user input.


okay but How shall I do this ?

Do i need one Button or 2 buttons ?

#7 InTheCrease

InTheCrease

    Canucks Rookie

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,603 posts
  • Joined: 07-July 06

Posted 04 November 2012 - 03:22 PM

Shouldn't you be actually trying to learn this?

Well, for starters you could say what exactly you are having trouble with. The assignment is simple enough that no general help can be given without basically doing it for you.


Exactly what happened in his other post 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).
QUOTE
I played for the Leafs for three years, Im used to the booing so it wont affect me - Kyle Wellwood

#8 Zach Parise

Zach Parise

    Canucks First-Line

  • Members
  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 6,411 posts
  • Joined: 20-March 09

Posted 04 November 2012 - 04:13 PM

Shouldn't you be actually trying to learn this?


Exactly what happened in his other post 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).


that assignment i did some adjustments because teacher asked to make sure the file is saved in a txt format so it opens in notepad. and it worked So thanks for that.

Also on this assignment I cant seem to get it done.

ill give you the code hold up what ive done so far

#9 butters

butters

    Canucks Rookie

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,525 posts
  • Joined: 23-July 04

Posted 04 November 2012 - 05:01 PM

Also on this assignment I cant seem to get it done.


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.

#10 Zach Parise

Zach Parise

    Canucks First-Line

  • Members
  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 6,411 posts
  • Joined: 20-March 09

Posted 04 November 2012 - 05:10 PM

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.


I dont know how to lay out it on the Form , All i have is a calculate Button and Exit Button, Do i Need a Label ?

#11 butters

butters

    Canucks Rookie

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,525 posts
  • Joined: 23-July 04

Posted 04 November 2012 - 06:25 PM

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.

#12 InTheCrease

InTheCrease

    Canucks Rookie

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,603 posts
  • Joined: 07-July 06

Posted 04 November 2012 - 06:36 PM

I dont know how to lay out it on the Form , All i have is a calculate Button and Exit Button, Do i Need a Label ?



The exit button isn't really needed if this is a windows form.

If you have a calculate button, how is the application getting the user input? Are you hard coding the values in the code? I assume you would need to have a place for the user to enter the carb/fat info

Once you press the calculate button, where are you displaying the result? You will need a label or something (unless this has to go to text file as well?)

As far as laying it out goes, how do you imagine it looking? How about you:

* Post a screen shot of your form
* Explain how you have it laid out and why you did it that way (or how you are going to do it).
* Explain what each button does and the function it calls
* How you are displaying the result (where)


You will likely get asked why you did it the way you did, as there are multiple ways to accomplish the task that has been assigned.

Edited by InTheCrease, 04 November 2012 - 06:39 PM.

QUOTE
I played for the Leafs for three years, Im used to the booing so it wont affect me - Kyle Wellwood

#13 Zach Parise

Zach Parise

    Canucks First-Line

  • Members
  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 6,411 posts
  • Joined: 20-March 09

Posted 04 November 2012 - 07:46 PM

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 !

Posted Image

Edited by Zach Parise, 04 November 2012 - 07:49 PM.


#14 Zach Parise

Zach Parise

    Canucks First-Line

  • Members
  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 6,411 posts
  • Joined: 20-March 09

Posted 04 November 2012 - 07:58 PM

Any help guys ?

Am i on the right track ?

#15 Peaches

Peaches

    Canucks Star

  • Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • 8,910 posts
  • Joined: 03-February 12

Posted 04 November 2012 - 08:04 PM

A hockey forum probally isn't the best place for help.

Try asking a teacher or something.

Feminism will be outlawed. Mostly because it's a backwards idiotic viewpoint that doesn't serve any real progressive purpose.


Nobody breaks from Mafia... Mafia breaks YOU!

CDCEHL - Winnipeg Jets AGM


#16 butters

butters

    Canucks Rookie

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,525 posts
  • Joined: 23-July 04

Posted 04 November 2012 - 08:30 PM

I don't see grams anywhere... input should be in grams. But you are on the right track over all.




Canucks.com is the official Web site of The Vancouver Canucks. The Vancouver Canucks and Canucks.com are trademarks of The Vancouver Canucks Limited Partnership.  NHL and the word mark and image of the Stanley Cup are registered trademarks and the NHL Shield and NHL Conference logos are trademarks of the National Hockey League. All NHL logos and marks and NHL team logos and marks as well as all other proprietary materials depicted herein are the property of the NHL and the respective NHL teams and may not be reproduced without the prior written consent of NHL Enterprises, L.P.  Copyright © 2009 The Vancouver Canucks Limited Partnership and the National Hockey League.  All Rights Reserved.