473,395 Members | 1,948 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,395 software developers and data experts.

Randomizing Calculation Variables.

Hi everyone!

I'm currently working on a project where I have no idea where to begin because I'm really bad at programming and thus, the reason why I'm posting here. To start off with, my project supervisor wants us to use the following programs:

1. Visual Web Developer
2. Visual Basic
3. SQL

He wants us to come up with a code that allows users to enter a equation but the variables can be randomized, meaning...

y = mx + c

The variables being 'x' and 'c'.

So after you type in y = mx + c (most likely must come up with interface), the variables are to randomize themselves every time a person starts the quiz.

*Must not be hard coded.


The users are people who do not care what goes on behind the scenes, meaning, they want nothing to do with the codings, and it must be user friendly. How will I be able to make the codings work like that based on the code language that I am allowed to work with.

Thanks for the help in advance!
- Denise

p/s You can email me at denisetay17@hotmail.com
Sep 2 '08 #1
11 1622
vdraceil
236 100+
One thing you can do is make a list of all the equations you think the use might use,prompt the user to click any one of them and then ask the user to enter values for respective variables.

Another method is you can get the equation in a string variable,calc the number of variables involved(excluding the numbers and operators all other characters are variables),form a general equation,compare it with the list of equations you have to confirm to which type the entered equation belongs.

i do have something else to say..this site is not for training people who are bad at programming,rather a site for developers across the world to share their views and ways of solving general problems.
Sep 2 '08 #2
kadghar
1,295 Expert 1GB
^.^

First of all, you'll need something to evaluate mathematical expressions, check this article out.

once you can evaluate them, you can do something like this (using the EVAL function from the article), please note this is a simple example and it can clearly be improved (so can the articles' code):

Expand|Select|Wrap|Line Numbers
  1. 'this little example will search every letter form a to z, using its ascii code (from 97 to 122) and the REPLACE function.
  2. '
  3. dim str1 as string
  4. dim i as integer
  5. randomize
  6. str1= inputbox("write the function here")
  7. for i = 97 to 122
  8.     str1=replace(str1, chr(i),rnd*100)
  9. next
  10. msgbox str1 & " = " & eval(str1)
I think that'll give you a good idea, and can be quite general for any purpose

I tried it with a+b*c (it'll give you the other side, son dont write both sides of ecuation, write only one) and returned:

81.59072+74.97083*78.8576 = 5993.610443808

^.^ nice!!

Anyway, im sure that with some time you can improve this quite a bunch.

HTH
Sep 2 '08 #3
Oh thanks for the help everyone :) Really appreciate it. Gotta do up the interface first and even tho' I don't really understand the codes, I'll do the best of my ability. Lol.
Sep 3 '08 #4
One thing you can do is make a list of all the equations you think the use might use,prompt the user to click any one of them and then ask the user to enter values for respective variables.

Another method is you can get the equation in a string variable,calc the number of variables involved(excluding the numbers and operators all other characters are variables),form a general equation,compare it with the list of equations you have to confirm to which type the entered equation belongs.

i do have something else to say..this site is not for training people who are bad at programming,rather a site for developers across the world to share their views and ways of solving general problems.

I merely asked a question that you could have chosen not to reply. The website says I could ask questions. It doesn't say you can't ask, if you're bad at programming. Thanks for your reply but you didn't understand the question in the first place.
Sep 3 '08 #5
vdraceil
236 100+
I merely asked a question that you could have chosen not to reply. The website says I could ask questions. It doesn't say you can't ask, if you're bad at programming. Thanks for your reply but you didn't understand the question in the first place.
Sorry buddy..i didnt mean to hurt you..really sorry
Sep 3 '08 #6
Sorry buddy..i didnt mean to hurt you..really sorry
Sorry too, I'm just running out of places to get help. :(
Sep 4 '08 #7
kadghar
1,295 Expert 1GB
Sorry too, I'm just running out of places to get help. :(
dont worry, i think we can work this out quite fine. ^.^

did you get to make it work?
Sep 4 '08 #8
I used another method to make it work but I haven't figured out how to integrate the randomization code into it yet. I just managed to do up the interface and make y=mx+c
Sep 5 '08 #9
jg007
283 100+
at the moment I don't have anything to add but I would really recomend against posting your email address in a public forum as it is all too easy to get on a spammers list and it is a much better option to state that you can be pm'd

if you do wish to post an email address it is better to try and hide it from some of the spider programs by at least removing the @ sign

Somebody<insert @ here>anywhere.net
Sep 5 '08 #10
jg007
283 100+
quick example code for random numbers as above looks a little complicated

Expand|Select|Wrap|Line Numbers
  1.         Dim y, m, x, c As Integer
  2.         m = 1
  3.  
  4.         Randomize()
  5.         x = 50 * Rnd() ' random number up to 50
  6.         c = 50 * Rnd() ' random number up to 50
  7.         y = m * x + c
  8.  
  9.         MsgBox(y)
  10.  
  11.  
Sep 5 '08 #11
[quote=jg007]quick example code for random numbers as above looks a little complicated

Expand|Select|Wrap|Line Numbers
  1.         Dim y, m, x, c As Integer
  2.         m = 1
  3.  
  4.         Randomize()
  5.         x = 50 * Rnd() ' random number up to 50
  6.         c = 50 * Rnd() ' random number up to 50
  7.         y = m * x + c
  8.  
  9.         MsgBox(y)
  10.  
  11.  
[/QUOTE

Thanks for the tip and the quick example. I'll remove my email asap :)
Sep 8 '08 #12

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

Similar topics

2
by: Susanna | last post by:
Hi all, I'm using the following slideshow script that I found on the web to display changing images with a crossfade effect. Eventually I will be adding many more images to the slideshow. The...
10
by: Michael G | last post by:
double A = floor((2447297.0 - 122.1)/365.25); i get differing results. It varies between 6699 and 6700. The correct answer is 6699. The 6700 result really throws the entire group of calculations...
0
by: anaxamandr | last post by:
Hi. I have a long loop in ASP that performs a rather lengthy calculation. I would love for my users to be able to stop that calculation, if they so choose, mid way through the process. I attempted...
7
by: th-ko | last post by:
Hi, I would like to know whether a certain coding pattern exist to handle the following problem. I am using a const methode to get and value a from the class. In case the value was not calculated...
28
by: beach.dk | last post by:
Hi, I'm trying to implement a simple hash algorith called rs_hash in javascript, but I cannot get a correct result. In c the code looks like this:
2
by: andre.ditador9999 | last post by:
I want to randomize a certain calculation in Python but haven't figured it out yet. To explain what i mean, I' m going to use an example: I want to get the numbers to do a random experience...
5
by: The alMIGHTY N | last post by:
Hi all, Let's say I have a simple math formula: sum (x * y / 1000) / (sum z / 1000) I have to do this across 50 items, each with an x, y and z value, when the page first loads AND when a...
19
by: LucasLondon | last post by:
Hi there, First of all apologies for the long post. Hope someone can offer some advice. I have about 200 columns of time series data that I need to perform a correlation analysis on in terms...
5
by: =?Utf-8?B?ZG9uZGlnaXRlY2g=?= | last post by:
I having problems getting this function to return the correct value. Basically I have a curveDataCalc method that loops as it should, but just doesn't seem to be working right. I've stepped through...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.