Answer to Question #16049 in C# for Vikash

Question #16049
hi i have a question on my homework

i have homework for my programming course and im using the book C# visual studio 2010 text book

and my prof has assigned a question for us to do , and Im having trouble coding the work.

so heres the question. pg 335 question 7.

Running on a particular treadmill, you burn 3.9 calories per minute. create an application that uses the loop to display the number of calories burned after 10,15,20,25,30 minutes. display the output in a LISTBOX control.

please help me out here thanks.
1
Expert's answer
2012-10-09T08:55:32-0400
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 Question_16049
{
public partial class Form1 : Form
{
& public Form1()
& {
InitializeComponent();
& }

& private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
& {
string s = listBox1.SelectedIndex.ToString();
switch (s)
{
case "0":
& textBox1.Text = "You burned 39 calories";
& break;
case "1":
& textBox1.Text = "You burned " + (3.9 * 15).ToString() + " calories";
& break;
case "2": textBox1.Text = "You burned " + (3.9 * 20).ToString() + " calories";
& break;
case "3": textBox1.Text = "You burned " + (3.9 * 25).ToString() + " calories";
& break;
case "4": textBox1.Text = "You burned " + (3.9 * 30).ToString() + " calories";
& break;
default:
& textBox1.Text = "";
& break;
}
& }
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS