473,396 Members | 2,010 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.

I don't get it?!?

2
i have to write a program for a class i'm in to caclulate the price of carpet in square yards when the user inputs length and width in feet, but i keep getting the error message "use of unassiged local variable 'variableName'". How might I fix this???


Here's the code


using System;
using System.Collections.Generic;
using System.Text;

namespace Yards
{
class Program
{
static void Main(string[] args)
{
double carpetPrice = 2.99;
double squareFeet, squareYards, finalPrice;
int length, width, value = 9;
string lengthStr, widthStr, carpetPriceStr;




squareFeet = length * width;
squareYards = squareFeet / value;
finalPrice = squareYards * carpetPrice;



Console.WriteLine("Enter the length of the room.");
lengthStr = Console.ReadLine();
length = Convert.ToInt32(lengthStr);
Console.WriteLine("Enter the width of the room.");
widthStr = Console.ReadLine();
width = Convert.ToInt32(widthStr);
Console.WriteLine("Enter carpet price per square yard.");
carpetPriceStr = Console.ReadLine();
carpetPrice = Convert.ToDouble(carpetPriceStr);
Console.WriteLine("The total price is {0}", finalPrice.ToString("C"));

Console.ReadLine();
}
}
}
Sep 21 '07 #1
2 860
Plater
7,872 Expert 4TB
Well this should actually be pretty obvious.
You're trying to use length and width before assigning them values.
You need to do your Console commands first.
Sep 21 '07 #2
Omar09
2
yes i realized this like 10 minutes after looking it over, so thanks
Sep 21 '07 #3

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

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
28
by: DFS | last post by:
I'm unfortunately about to change, or sever, a two-year relationship with a very slow-paying client. Most of the 15 invoices I've sent them arrive 6 to 8 weeks late, and usually only after...
0
by: Nashat Wanly | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaskdr/html/askgui06032003.asp Don't Lock Type Objects! Why Lock(typeof(ClassName)) or SyncLock GetType(ClassName) Is Bad Rico...
19
by: LP | last post by:
I am using (trying to) CR version XI, cascading parameters feature works it asks user to enter params. But if page is resubmitted. It prompts for params again. I did set...
10
by: Frank | last post by:
I've done this a few times. In a solution I have a project, Say P1, and need another project that will contain much code that is similar to that of P1. I hope no one gets hung up on why I...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.