Beginner Problems

S

Samara Galvao

I am a beginner, and I am having problems trying to solve some basic
questions. Can anyone help me?

Those are the problems I am trying to solve.

Q1)
There is a list of 1,000,000 usernames stored in a zero-based string
array. The usernames are in alphabetic order. The programming language
you are using has no automated method for searching arrays to find
matches. Language functions at your disposal are:

Lbound(array) Gets the lowest index of an array
Ubound(array) Gets the highest index of an array
Round(decimal) Rounds up or down decimal values

Strcomp(string1, string2) Returns 0 if a match is found
Returns 1 if string2 is lower in the alphabet than string1
Returns -1 if string2 is higher in the alphabet that string1

What type of method would you use to search for a specific username?
Write a simple code.


Q2)
The following information is contained in a spreadsheet, and is used by
a computer retailer to determine the products that are in-stock at their
various stores.

Store City Product Price Quantity
Virginia Outlet #1 Vienna Hypertext Builder 12.00 30
Washington Outlet #1 Redmond Hypertext Builder 12.00 30
Virginia Outlet #1 Vienna Windows XP Home 199.00 20
Washington Outlet #1 Redmond Windows XP Home 199.00 60
Illinois Outlet #44 Chicago Windows XP Home 199.00 80
Washington Outlet #1 Redmond Extera Design Suite 222.00 130

Create a database table schema that expresses the above information in a
normalized fashion.


Q3)
There are two database tables, one that stores customers and one that
stores addresses. They have the following structures

tCustomer
Customer_ID int Primary Key
First_Name varchar(255)
Last_Name varchar(255)
Email varchar(255)

tCustomer_Address
Address_ID int Primary Key
Address1 varchar(255)
Address2 varchar(255)
Address3 varchar(255)
State varchar(4)
City varchar(255)
Zip varchar(16)
Customer_ID int Foreign Key: tCustomer.Customer_ID

Write one query that will return the following information about each
customer.

First Name, Last Name
Address 1, Address 2, Address 3, State, City, Zip


A customer should appear in the results even if he/she does not have an
address in the database. In the event a customer has multiple
addresses, it is acceptable that their name shows up in the results more
than once.

Q4)
A candy company sells candy bars, and utilizes software to gauge a
variety of factors related to the product. What they need is a class
that:

Exposes the following properties:

Weight (in ounces)
Price (in dollars)
Fat Content
Calories
Taste Ranking
(1 to 10, 1 = tastes like health food, 10 = tastes awesome)

Provides the following functions:

A function that returns fat content per ounce
A function that returns calories per ounce
A function that returns price per ounce

Using Java/C#/VB/VB.NET, create a class that delivers the above, and
demonstrate how it might be utilized in surrounding code.
 
F

Finn Stampe Mikkelsen

Samara Galvao said:
I am a beginner, and I am having problems trying to solve some basic
questions. Can anyone help me?

Those are the problems I am trying to solve.

Q1)
There is a list of 1,000,000 usernames stored in a zero-based string
array. The usernames are in alphabetic order. The programming language
you are using has no automated method for searching arrays to find
matches. Language functions at your disposal are:

Lbound(array) Gets the lowest index of an array
Ubound(array) Gets the highest index of an array
Round(decimal) Rounds up or down decimal values

Strcomp(string1, string2) Returns 0 if a match is found
Returns 1 if string2 is lower in the alphabet than string1
Returns -1 if string2 is higher in the alphabet that string1

What type of method would you use to search for a specific username?
Write a simple code.


Q2)
The following information is contained in a spreadsheet, and is used by
a computer retailer to determine the products that are in-stock at their
various stores.

Store City Product Price Quantity
Virginia Outlet #1 Vienna Hypertext Builder 12.00 30
Washington Outlet #1 Redmond Hypertext Builder 12.00 30
Virginia Outlet #1 Vienna Windows XP Home 199.00 20
Washington Outlet #1 Redmond Windows XP Home 199.00 60
Illinois Outlet #44 Chicago Windows XP Home 199.00 80
Washington Outlet #1 Redmond Extera Design Suite 222.00 130

Create a database table schema that expresses the above information in a
normalized fashion.


Q3)
There are two database tables, one that stores customers and one that
stores addresses. They have the following structures

tCustomer
Customer_ID int Primary Key
First_Name varchar(255)
Last_Name varchar(255)
Email varchar(255)

tCustomer_Address
Address_ID int Primary Key
Address1 varchar(255)
Address2 varchar(255)
Address3 varchar(255)
State varchar(4)
City varchar(255)
Zip varchar(16)
Customer_ID int Foreign Key: tCustomer.Customer_ID

Write one query that will return the following information about each
customer.

First Name, Last Name
Address 1, Address 2, Address 3, State, City, Zip


A customer should appear in the results even if he/she does not have an
address in the database. In the event a customer has multiple
addresses, it is acceptable that their name shows up in the results more
than once.

Q4)
A candy company sells candy bars, and utilizes software to gauge a
variety of factors related to the product. What they need is a class
that:

Exposes the following properties:

Weight (in ounces)
Price (in dollars)
Fat Content
Calories
Taste Ranking
(1 to 10, 1 = tastes like health food, 10 = tastes awesome)

Provides the following functions:

A function that returns fat content per ounce
A function that returns calories per ounce
A function that returns price per ounce

Using Java/C#/VB/VB.NET, create a class that delivers the above, and
demonstrate how it might be utilized in surrounding code.

Sounds to me, like you are an IT student, who looks to this group for the
answers to a school project. If so, what would you learn from that ?? You
would only cheat yourself...

If not so, then excuse me, but looking from the beginners prospective and
remembering my own rute to where i am now, i would think it a challange
worth taking, to play around with VS and C#/VB.NET and trying to solve the
questions myself.

But my 2 cents are on this being a school project (classroom quiz) or
similar...

/Finn
 
P

Peter Duniho

I am a beginner, and I am having problems trying to solve some basic
questions. Can anyone help me? [...]

Maybe you could be more clear about the context. The questions you posted
look a lot like classwork. It's generally frowned upon to ask other
people to do your classwork for you, and most people will simply refuse to
help at all.

You would do better to explain exactly why you have these questions, and
what it is about them you specifically need help with. All four of the
questions have relatively simple answers, for a person who knows the
material. But giving you a literal answer isn't going to help you
understand the questions or answers at all.

If you have some aspect of the question that is specific to C# and you
would like help working that specific thing out, please feel free to ask
for help with that, being sure to state your question in a clear, specific
way.

But, if you're simply lost with respect to what these questions are even
asking, never mind where you'd start in answering them, you really need to
consult the teacher involved in presenting the questions. Newsgroup help
isn't going to get you anywhere.

Pete
 
S

Samara Galvao

I guess I should just wait for my class to start.
I understand what you are saying...
 
S

Samara Galvao

I understand what the questions are asking, my problem is translating it
to code. For example, question one I know I could do an index search,
that compares the first character of the name I am looking for, if
there is a match I compare the second character and so on. For that
matter I would have to do a loop. However, when is time to write the
code, I get completely lost. I am really a beginner who is trying to
learn on my own for now. I want to be a step ahead when my class start.
Sorry about my writing, English is my second language.
 
P

Peter Duniho

I understand what the questions are asking, my problem is translating it
to code. For example, question one I know I could do an index search,
that compares the first character of the name I am looking for, if
there is a match I compare the second character and so on. For that
matter I would have to do a loop. However, when is time to write the
code, I get completely lost. I am really a beginner who is trying to
learn on my own for now. I want to be a step ahead when my class start.
Sorry about my writing, English is my second language.

Your heart's in the right place, but IMHO you're going about it the wrong
way. The point of the class is to have a teacher help you learn the
material. If you want a head start, hire a tutor, because you are
basically trying to learn the class curriculum before the class starts.
Learning the class curriculum is going to take roughly the same amount of
time that would be spend learning it in class. That's a lot more
information than is practical to try to convey in a newsgroup.

Personally, I'd just wait for the class to start and learn the material
then. Alternatively, skip the class altogether and get a tutor to teach
you the material. I don't see the point in spend the time and money on
the material twice.

Pete
 
J

J.B. Moreno

Samara Galvao said:
I understand what the questions are asking, my problem is translating it
to code. For example, question one I know I could do an index search,
that compares the first character of the name I am looking for, if
there is a match I compare the second character and so on. For that
matter I would have to do a loop. However, when is time to write the
code, I get completely lost. I am really a beginner who is trying to
learn on my own for now. I want to be a step ahead when my class start.
Sorry about my writing, English is my second language.

1) As rossum said, you don't have to compare the characters in the
username 1 by one.
2) Your teacher/book is after a specific type of search.
3) Avoiding getting lost is something you're going to have to work out
yourself. There are various different ways, but which one will work
best for you is going to be personal. You might start rough and large
and then refine it. You might try doing it by hand first (with a
smaller dataset of course) and record all of the steps you take in
order to solve the problem.

Just remember that what you're doing is taking a word problem and
turning it into a word solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top