This time just a simple example of grading scores (0 - 100) with letters (A - F). Two approaches are presented, one using switch/case in an "on the fly" function, and the other uses the score as an index to a string of letters F through A.

Member Avatar
Member Avatar
+1 forum 1

Hello, i was wondering if i could get an opinion on the following code as it is giving me a headache: int counter = 498853097; int k = 0; clock_t start, end; float seconds1,seconds2; start = clock(); for (int i = 0; i < counter; i++) { k++; } end = clock(); seconds2 = (float)(end - start) / CLOCKS_PER_SEC; start = clock(); for (int i = 0; i < counter; i++); end = clock(); seconds1 = (float)(end - start) / CLOCKS_PER_SEC; printf("\n Time 2 [%f] - Time 1 [%f] = %f",seconds2,seconds1,seconds2-seconds1); It's the exact same repetition twice, except one of …

Member Avatar
Member Avatar
+0 forum 2

Hey guys ..!! so today I was solving another problem involving a loop in it and i'm not sure exactly how to apply that condition to repeat it unless the terminating condition becomes true. I tried to do it on my own but its not working. can anyone of you please tell me how to do it correctly. MY CODE.. #include<iostream> #include<conio.h> using namespace std; int main() { int num; float centigrade, fahrenheit, result; cout<<"Please select from the following options. Press (1 or 2). \n1.Centigrade to Fahrenheit. \n2.Fahrenheit to Centigrade."<<endl; cin>>num; while( num == 1 || num == 2 || …

Member Avatar
Member Avatar
+0 forum 1

I'm currently working on a collection of sub-projects, one of which was a backup manager. I needed to be able to allow the user to specify a backup time and a repeat interval. After thinking about the solution, decided it would be best for the user to provide an Initial DateTime of the first occurance and how frequent they would like to repeat the event. This class can be used to help determaine Alarms, Reminders or anything that requires an event to be triggered at a certain time. >Fun and Good for Beginners It was good fun writing this wee …

Member Avatar
Member Avatar
+1 forum 2

I have an image set as my background, which fades from blue to white and I'm just wondering if anyone knows how I can vertically repeat the image, but make the second one upside-down?

Member Avatar
Member Avatar
+0 forum 2

**Background**: I have some experience in programming, but it's not a lot and not very good. I'm taking my first Java class this year, but because the pace is so slow I decided to just learn with the aid of the internet. This is how I have learned most of what I know so far. The most recent thing I've learned are Sockets, if that gives you an idea of what level I'm at. **Context**: I am creating a small multiplayer game played through a standalone applet: a 2D shooter where the player(s) have to defeat a barrage of NPC …

Member Avatar
Member Avatar
+0 forum 3

**Hey i'm creating basic a shopping cart for a uni project, everything works however when I select the view cart button on my html page it appears, however if i select it repeatedly, the table creates a replica table below and does this everytime I select my button so I end up with lots of tables at the bottom of my page. Can anyone help!** //create the new arrays var namesArray = new Array(); var quantityArray = new Array(); var sumArray = new Array(); var priceArray = new Array(); var totalPriceArray = new Array(); var titleArray = new Array(); //add …

Member Avatar
Member Avatar
+0 forum 1

Ok, I am walking my way through an instructional php book and basically going over the basics again. After I finished doing the script the way the book said to do it, I kept getting a header error saying that the headers have already been submitted. The book had my echo statements spread out all over the place instead of just doing a self processing file. You know? The kind that looks back at itself for print commands once a submit button his clicked. SO I modified the file to be self contained. Seems to work with just one problem …

Member Avatar
Member Avatar
+0 forum 5

Hi guys, So I write this program so far.. 1 //exercise15.cpp - displays a pattern of asterisks 2 //Created/revised by <harde> 3 4 #include <iostream> 5 using namespace std; 6 7 int main() 8 { 9 for (int outer = 2; outer < 11; outer += 2) 10 { 11 for (int nested = 1; nested <= outer; nested += 1) 12 cout << '*'; 13 //end for 14 cout << endl; 15 } //end for 16 17 system("pause"); 18 return 0; 19 } //end of main function Next is.. MOdifying the program on top ^ to this.. The modified …

Member Avatar
+0 forum 0

I want to translate text inputted multiple times then output it. I am using the maketrans() function. I want to translate multiple times, by a number of times a user would input.

Member Avatar
Member Avatar
+0 forum 8

Hi, I'm looking to code the following problem in python. If (for example) dict={A:0.7,B:0.8,C:0.9,D:2.3,E:0.1,F:2.4} and so on.. (i have a big dictionary of A-Z something like this) I'm looking to find repeated substring in a string that has a dissimilarity of no longer than 0.5 (between highest and lowest). The length of the repeated substring is provided by the user. So For example , If my string is ABCFFEABCFEBCA my answer would be ABC (with its positions), ABC(with positions in the string) and BCA(with positions in a string) (if the length of the substring provided by the user is 3) …

Member Avatar
Member Avatar
+0 forum 3

Hi guys, I've just managed to get 99% of a script running for my website. I am creating a system where a user can create an invoice using our billing system, and then download it via PDF. I am using Persists PDF module and I have got it all working. However, there is just one thing I am unable to figure out. I can't seem to repeat a particular part of the string used by the PDF module. I am using dynamic data successfully to populate the data created in the PDF, but my repeat region refuses to repeat my …

Member Avatar
Member Avatar
+0 forum 28

Okay. I am creating a program for school and I am a beginner to python. Here is my code: [CODE] intro = input("Want to play a game of number guess? ") while intro == 'yes': print("\nOkay. Just guess the number I am thinking of from 1 to 10.) if intro != 'yes' or 'no': print("\nThat command is not in my program. Try again: ") intro = input() #This is supposed to let you retype your answer to the question if you did not type in no or yes if intro == 'no': choice = exit() slot = input("\nInsert 50 cents …

Member Avatar
Member Avatar
+0 forum 1

I'm mentally stuck. I'm trying to create 3 divs side-by-side with the 2 outter divs containing a repeating background in opposite directions of each other with a fixed width middle div. The background image for the left div needs to begin its alignment where it meets the middle div and repeat to the left. Same but opposite thing for the right div. My reasoning is because I have a background image that is (say 380 px wide). The middle div will be exactly 380 px and centered in the browser. For reasons I don't think are important, I need to …

Member Avatar
Member Avatar
+0 forum 6

Hi I'm pritty new to C# I'm having trouble with items repeating in a combo box This method gets the values from my table and stores it in the list of strings which it does fine . . . I think. [CODE]public class EditStates { public List<string> getStates(CEditStates ced) { string typeSelected = (string)ced.cb1.SelectedItem; string states = "SELECT State FROM MyTables.StateDefaults WHERE ObjectTypeID = '" + typeSelected + "'"; SqlCommand cmd = new SqlCommand(states, db.Connect()); SqlDataReader reader; List<string> objStates = new List<string>(); try { reader = cmd.ExecuteReader(); while (reader.Read()) { objStates.Add(reader["State"].ToString()); } reader.Close(); } catch { MessageBox.Show("Failed to retreive object …

Member Avatar
Member Avatar
+0 forum 1

Hi, I have a fancy animated GIF loader that I want to use in projects, but the problem is that the image is only 48x22. Is there some way I can tile the image horizontally to lengthen it? The only solutions I found on the web was with bitmap images. Any ideas? Thanks!

Member Avatar
Member Avatar
+0 forum 1

Hello - I am trying to get a looping date repeater to work but it is driving me crazy! It works for most dates but breaks for dates that originate in early November. I created a page that shows the code and the output for anyone to see what is going on. The page is here: [URL="http://www.countyharvest.org/loop.php"]loop test[/URL] Here is the code, which is also on the page. [CODE=php]$counter=0; $i=1; // TEST LOOP START $sequence = $_POST['sequence']; // days $repeat = $_POST['repeat']; // number of records $originaldate = $_POST['year'] ."-".$_POST['month'] ."-" . $_POST['day']; // BREAKS IN EARLY NOVEMBER!! while($i<=$repeat) { …

Member Avatar
Member Avatar
+0 forum 3

Please help me with the End on this problem. I just can't seem to finish it off properly. I keep getting a parse error on the last End. program ValueParameters (input,output); {Author: Cheryl Wahlheim Class: CS241XP Assignment: User Income and Tax Rate procedure} Var income, taxrate, totaltaxdue : real; response : char; Procedure Taxes; Begin writeln('Welcome to Your Friendly Tax Service'); writeln('Your declared income is $',income:8:2); writeln('Your tax rate is ',taxrate:2:2,'%'); writeln('Your Total Tax Due is $',totaltaxdue:7:2) End; Begin writeln('Enter your income and tax rate.'); writeln('Note: tax rate should be entered as a percentage.'); readln; totaltaxdue := income*(taxrate/100); Begin Repeat …

Member Avatar
Member Avatar
+0 forum 1

The End.