Search Results

Search found 1552 results on 63 pages for 'homework'.

Page 10/63 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Computer science final year project ideas

    - by roul
    I'm a Computer Science undergraduate student in UK and should be deciding the subject of my final year project soon. The school is pretty flexible with the subject... "The topic can be any area of the subject which is of mutual interest to both the student and supervisor. Topics can range from purely theoretical studies to practical work building a system for some third party, although most projects aim to provide a balance between the theoretical and practical aspects of the subject." ...so I'm a bit lost since I want to do something in software engineering but have no idea what (subject) or with what (languages)! :) a) Languages: I've had experience with Java, C# and ASP.NET mostly but I would definitely be interested in learning new languages/frameworks. I'm kind of drawn by the idea of dynamic languages at the moment so IronPython seems likely. b) Subject: Anything that will keep me interested through the year and will give me the opportunity to learn a lot of stuff. Maybe something that has to do with music, or a fancy website, or a website about music :P anything really. Open to any thoughts/ideas, geeky or cool! Edit: Professors do usually supervise projects in their research areas but I currently have the choice to approach any of them according to my interest - whatever that is.

    Read the article

  • What's wrong with this conditional?

    - by David
    I am trying to make a method that tests to see if 3 lengths can make a triangle. I think i'm making some kind of syntax error but i can't figure out what it is. Here is the relevant bit of code: (its in java) public static void trya (int a, int b, int c) { if (c>(a+b)) { System.out.println ("yes") ; } else { if (b>(a+c)) { System.out.println ("yes") ; } } else { if (a>(b+c)) { System.out.println ("yes") ; } } else { System.out.println ("no") ; } } this is the error message i get: tryangle.java:17: 'else' without 'if' else ^

    Read the article

  • branch prediction

    - by Alexander
    Consider the following sequence of actual outcomes for a single static branch. T means the branch is taken. N means the branch is not taken. For this question, assume that this is the only branch in the program. T T T N T N T T T N T N T T T N T N Assume a two-level branch predictor that uses one bit of branch history—i.e., a one-bit BHR. Since there is only one branch in the program, it does not matter how the BHR is concatenated with the branch PC to index the BHT. Assume that the BHT uses one-bit counters and that, again, all entries are initialized to N. Which of the branches in this sequence would be mis-predicted? Use the table below. Now I am not asking answers to this question, rather than guides and pointers on this. What does a two level branch predictor means and how does it works? What does the BHR and BHT stands for?

    Read the article

  • Manipulating matrix operations (transpose, negation, addition, and mutiplication) using functions in

    - by user292489
    I was trying to manipulate matrices in my input file using functions. My input file is: A 3 3 1 2 3 4 5 6 7 8 9 B 3 3 1 0 0 0 1 0 0 0 1 C 2 3 3 5 8 -1 -2 -3 D 3 5 0 0 0 1 0 1 0 1 0 1 0 1 0 0 1 E 1 1 10 F 3 10 1 0 2 0 3 0 4 0 5 0 0 2 3 -1 -3 -4 -3 8 3 7 0 0 0 4 6 5 8 2 -1 10 I am having trouble in implementing the functions that I declared. I assumed my program will perform those operations: transpose, negate, add, and multiply matices according to the users choice: /* once this program is compiled and executed, it will perform the basic matrix * operations: negation, transpose, addition, and multiplication. */ #include <stdio.h> #include <stdlib.h> #define MAX 10 int readmatrix(FILE *input, char martixname[6],int , mat[10][10], int i, int j); void printmatrix(char matrixname[6], int mat[10][10], int i, int j); void Negate(char matrixname[6], int mat[10][10], int i, int j); void add(char matrixname[6], int mat[10][10],int i, int k); void multiply(char matrixname[], int mat[][10], char A[], int i, int k); void transpose (char matrixname[], int mat[][10], char A[], int); void printT(int mat[][10], int); int selctoption(); char selectmatrix(); int main(int argc, char *argv[]) { char matrixtype[6]; int mat[][10]; FILE *filein; int size; int optionop; int matrixop; int option; if (argc != 2) { printf("Usage: executable input.\n"); exit(0); } filein = fopen(argv[1], "r"); if (!filein) { printf("ERROR: input file not found.\n"); exit (0); } size = readmatrix (filein, matrixtype); printmatrix(matrix[][10], size); option = selectoption(); matrixtype = selectmatrix(); //printf("You have: %5.2f ", deposit); optionop = readmatrix(option, matrix[][10], size); if (choiceop == 6) { printf("Thanks for using the matrix operation program.\n"); exit(0); } printf("Please select from the following matrix operations:\n") printf("\t1. Print matrix\n"); printf("\t2. Negate matrix\n"); printf("\t3. Transpose matrix\n"); printf("\t4. Add matrices\n"); printf("\t5. Multiply matrices\n"); printf("\t6. Quit\n"); fclose(filein); return 0; } do { printf("Please select option(1-%d):", optionop); scanf("%d", &matrixop); } while(matrixop <= 0 || matrixop > optionop); void readmatrix (FILE *in, int mat[][10], char A[], int i, int j) { int i=0,j = 0; while (fscanf(in, "%d", &mat[i][j]) != EOF) return 0; } // I would appreciate anyone's feedback.

    Read the article

  • Polygon triangulation

    - by Saurabh
    Hey, I am working on nesting of sheet metal parts and am implementing Minkowski Sums to find No Fit Polygons for nesting. The problem is I can give only convex sets as input to the code which calculates Minkowski sums for me. Hence I need to break a concave polygon, with holes into Convex sets. I am open to triangulation also, but I am looking for a working code on VC++ (6.0). I am slightly running short on time as my whole code is ready and just waiting for input in the form of convex sets. I would really appreciate if somebody with prior experience can help me in this. I have gone through other posts but did not find anything matching to this. I am a student of mechanical engineering and really dun have much idea about computer languages. All I can handle is compiling a code on VC++ and incorporate it with my existing code. Looking forward to responses!! Thanks Warm regards Saurabh India

    Read the article

  • Event Handlers Not Getting Called? - wxWidgets & C++

    - by Alex
    Hello all, I'm working on a program for my C++ programming class, using wxWidgets. I'm having a huge problem in that my event handlers (I assume) are not getting called, because when I click on the button to trigger the event, nothing happens. My question is: Can you help me find the problem and explain why they would not be getting called? The event handlers OnAbout and OnQuit are working, just not OnCompute or OnClear. I'm really frustrated as I can't figure this out. Thanks a bunch in advance! #include "wx/wx.h" #include "time.h" #include <string> using std::string; // create object of Time class Time first; class App: public wxApp { virtual bool OnInit(); }; class MainPanel : public wxPanel { public: // Constructor for panel class // Constructs my panel class // Params - wxWindow pointer // no return type // pre-conditions: none // post-conditions: none MainPanel(wxWindow* parent); // OnCompute is the event handler for the Compute button // params - none // preconditions - none // postconditions - tasks will have been carried otu successfully // returns void void OnCompute(wxCommandEvent& WXUNUSED(event)); // OnClear is the event handler for the Clear button // params - none // preconditions - none // postconditions - all text areas will be cleared of data // returns void void OnClear(wxCommandEvent& WXUNUSED(event)); // Destructor for panel class // params none // preconditions - none // postconditions - none // no return type ~MainPanel( ); private: wxStaticText *startLabel; wxStaticText *endLabel; wxStaticText *pCLabel; wxStaticText *newEndLabel; wxTextCtrl *start; wxTextCtrl *end; wxTextCtrl *pC; wxTextCtrl *newEnd; wxButton *compute; wxButton *clear; DECLARE_EVENT_TABLE() }; class MainFrame: public wxFrame { private: wxPanel *mainPanel; public: MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size); void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); ~MainFrame(); DECLARE_EVENT_TABLE() }; enum { ID_Quit = 1, ID_About, BUTTON_COMPUTE = 100, BUTTON_CLEAR = 200 }; IMPLEMENT_APP(App) BEGIN_EVENT_TABLE(MainFrame, wxFrame) EVT_MENU(ID_Quit, MainFrame::OnQuit) EVT_MENU(ID_About, MainFrame::OnAbout) END_EVENT_TABLE() BEGIN_EVENT_TABLE(MainPanel, wxPanel) EVT_MENU(BUTTON_COMPUTE, MainPanel::OnCompute) EVT_MENU(BUTTON_CLEAR, MainPanel::OnClear) END_EVENT_TABLE() bool App::OnInit() { MainFrame *frame = new MainFrame( _("Good Guys Delivery Time Calculator"), wxPoint(50, 50), wxSize(450,340) ); frame->Show(true); SetTopWindow(frame); return true; } MainPanel::MainPanel(wxWindow* parent) : wxPanel(parent) { startLabel = new wxStaticText(this, -1, "Start Time:", wxPoint(75, 35)); start = new wxTextCtrl(this, -1, "", wxPoint(135, 35), wxSize(40, 21)); endLabel = new wxStaticText(this, -1, "End Time:", wxPoint(200, 35)); end = new wxTextCtrl(this, -1, "", wxPoint(260, 35), wxSize(40, 21)); pCLabel = new wxStaticText(this, -1, "Percent Change:", wxPoint(170, 85)); pC = new wxTextCtrl(this, -1, "", wxPoint(260, 85), wxSize(40, 21)); newEndLabel = new wxStaticText(this, -1, "New End Time:", wxPoint(180, 130)); newEnd = new wxTextCtrl(this, -1, "", wxPoint(260, 130), wxSize(40, 21)); compute = new wxButton(this, BUTTON_COMPUTE, "Compute", wxPoint(135, 185), wxSize(75, 35)); clear = new wxButton(this, BUTTON_CLEAR, "Clear", wxPoint(230, 185), wxSize(75, 35)); } MainPanel::~MainPanel() {} MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& size) : wxFrame( NULL, -1, title, pos, size ) { mainPanel = new MainPanel(this); wxMenu *menuFile = new wxMenu; menuFile->Append( ID_About, _("&About...") ); menuFile->AppendSeparator(); menuFile->Append( ID_Quit, _("E&xit") ); wxMenuBar *menuBar = new wxMenuBar; menuBar->Append( menuFile, _("&File") ); SetMenuBar( menuBar ); CreateStatusBar(); SetStatusText( _("Hi") ); } MainFrame::~MainFrame() {} void MainFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { Close(TRUE); } void MainFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { wxMessageBox( _("Alex Olson\nProject 11"), _("About"), wxOK | wxICON_INFORMATION, this); } void MainPanel::OnCompute(wxCommandEvent& WXUNUSED(event)) { int startT; int endT; int newEndT; double tD; wxString startTString = start->GetValue(); wxString endTString = end->GetValue(); startT = wxAtoi(startTString); endT = wxAtoi(endTString); pC->GetValue().ToDouble(&tD); first.SetStartTime(startT); first.SetEndTime(endT); first.SetTimeDiff(tD); try { first.ValidateData(); newEndT = first.ComputeEndTime(); *newEnd << newEndT; } catch (BaseException& e) { wxMessageBox(_(e.GetMessage()), _("Something Went Wrong!"), wxOK | wxICON_INFORMATION, this); } } void MainPanel::OnClear(wxCommandEvent& WXUNUSED(event)) { start->Clear(); end->Clear(); pC->Clear(); newEnd->Clear(); }

    Read the article

  • a pdf reader - please guide - a step by step guidence - reference to guidence-

    - by user287745
    have to make a hardware project using micro controller, memory, screens, etc. is it possible to make an independent .dpf / documents reader, which is capable of running on battery power.? please note dont want to use any technology which needs licensing all free wares readers etc and programing say assembly and c or flash or any. please help, have submitted proposal of pdf reader project (independent hardware), many say its impossible, wht should i do??

    Read the article

  • running multi threads in Java

    - by owca
    My task is to simulate activity of couple of persons. Each of them has few activities to perform in some random time: fast (0-5s), medium(5-10s), slow(10-20s) and very slow(20-30s). Each person performs its task independently in the same time. At the beginning of new task I should print it's random time, start the task and then after time passes show next task's time and start it. I've written run() function that counts time, but now it looks like threads are done one after another and not in the same time or maybe they're just printed in this way. public class People{ public static void main(String[] args){ Task tasksA[]={new Task("washing","fast"), new Task("reading","slow"), new Task("shopping","medium")}; Task tasksM[]={new Task("sleeping zzzzzzzzzz","very slow"), new Task("learning","slow"), new Task(" :** ","slow"), new Task("passing an exam","slow") }; Task tasksJ[]={new Task("listening music","medium"), new Task("doing nothing","slow"), new Task("walking","medium") }; BusyPerson friends[]={ new BusyPerson("Alice",tasksA), new BusyPerson("Mark",tasksM), new BusyPerson("John",tasksJ)}; System.out.println("STARTING....................."); for(BusyPerson f: friends) (new Thread(f)).start(); System.out.println("DONE........................."); } } class Task { private String task; private int time; private Task[]tasks; public Task(String t, String s){ task = t; Speed speed = new Speed(); time = speed.getSpeed(s); } public Task(Task[]tab){ Task[]table=new Task[tab.length]; for(int i=0; i < tab.length; i++){ table[i] = tab[i]; } this.tasks = table; } } class Speed { private static String[]hows = {"fast","medium","slow","very slow"}; private static int[]maxs = {5000, 10000, 20000, 30000}; public Speed(){ } public static int getSpeed( String speedString){ String s = speedString; int up_limit=0; int down_limit=0; int time=0; //get limits of time for(int i=0; i<hows.length; i++){ if(s.equals(hows[i])){ up_limit = maxs[i]; if(i>0){ down_limit = maxs[i-1]; } else{ down_limit = 0; } } } //get random time within the limits Random rand = new Random(); time = rand.nextInt(up_limit) + down_limit; return time; } } class BusyPerson implements Runnable { private String name; private Task[] person_tasks; private BusyPerson[]persons; public BusyPerson(String s, Task[]t){ name = s; person_tasks = t; } public BusyPerson(BusyPerson[]tab){ BusyPerson[]table=new BusyPerson[tab.length]; for(int i=0; i < tab.length; i++){ table[i] = tab[i]; } this.persons = table; } public void run() { int time = 0; double t1=0; for(Task t: person_tasks){ t1 = (double)t.time/1000; System.out.println(name+" is... "+t.task+" "+t.speed+ " ("+t1+" sec)"); while (time == t.time) { try { Thread.sleep(10); } catch(InterruptedException exc) { System.out.println("End of thread."); return; } time = time + 100; } } } } And my output : STARTING..................... DONE......................... Mark is... sleeping zzzzzzzzzz very slow (36.715 sec) Mark is... learning slow (10.117 sec) Mark is... :** slow (29.543 sec) Mark is... passing an exam slow (23.429 sec) Alice is... washing fast (1.209 sec) Alice is... reading slow (23.21 sec) Alice is... shopping medium (11.237 sec) John is... listening music medium (8.263 sec) John is... doing nothing slow (13.576 sec) John is... walking medium (11.322 sec) Whilst it should be like this : STARTING..................... DONE......................... John is... listening music medium (7.05 sec) Alice is... washing fast (3.268 sec) Mark is... sleeping zzzzzzzzzz very slow (23.71 sec) Alice is... reading slow (15.516 sec) John is... doing nothing slow (13.692 sec) Alice is... shopping medium (8.371 sec) Mark is... learning slow (13.904 sec) John is... walking medium (5.172 sec) Mark is... :** slow (12.322 sec) Mark is... passing an exam very slow (27.1 sec)

    Read the article

  • Tuesday + 3 = Friday? C++ Programming Problem

    - by lampshade
    Looking at the main function, we can see that I've Hard Coded the "Monday" into my setDay public function. It is easy to grab a day of the week from the user using a c-string (as I did in setDay), but how would I ask the user to add n to the day that is set, "Monday" and come up with "Thursday"? It is hard because typdef enum { INVALID, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY} doesn't interpret 9 is 0 and/or 10 as 1. #include <iostream> using std::cout; using std::endl; class DayOfTheWeek //class is encapsulation of functions and members that manipulate the data. { public: DayOfTheWeek(); // Constructor virtual ~DayOfTheWeek(); // Destructor void setDay(const char * day); // Function to set the day void printDay() const; // Function to Print the day. const char * getDay() const; // Function to get the day. const char * plusOneDay(); // Next day function const char * minusOneDay(); // Previous day function const char * addDays(int addValue); // function that adds days based on parameter value private: char * day; // variable for the days of the week. }; DayOfTheWeek::DayOfTheWeek() : day(0) { // Usually I would allocate pointer member variables // Here in the construction of the Object } const char * DayOfTheWeek::getDay() const { return day; // we can get the day simply by returning it. } const char * DayOfTheWeek::minusOneDay() { if ( strcmp( day, "Monday" ) == 0) { cout << "The day before " << day << " is "; return "Sunday"; } else if ( strcmp( day, "Tuesday" ) == 0 ) { cout << "The day before " << day << " is "; return "Monday"; } else if ( strcmp( day, "Wednesday" ) == 0 ) { cout << "The day before " << day << " is "; return "Tuesday"; } else if ( strcmp( day, "Thursday" ) == 0 ) { cout << "The day before " << day << " is "; return "Wednesday"; } else if ( strcmp( day, "Friday" ) == 0 ) { cout << "The day before " << day << " is "; return "Thursday"; } else if ( strcmp( day, "Saturday" ) == 0 ) { cout << "The day before " << day << " is "; return "Friday"; } else if ( strcmp( day, "Sunday" ) == 0 ) { cout << "The day before " << day << " is "; return "Saturday"; } else { cout << "'" << day << "'"; return "is an invalid day of the week!"; } } const char * DayOfTheWeek::plusOneDay() { if ( strcmp( day, "Monday" ) == 0) { cout << "The day after " << day << " is "; return "Tuesday"; } else if ( strcmp( day, "Tuesday" ) == 0 ) { cout << "The day after " << day << " is "; return "Wednesday"; } else if ( strcmp( day, "Wednesday" ) == 0 ) { cout << "The day after " << day << " is "; return "Thursday"; } else if ( strcmp( day, "Thursday" ) == 0 ) { cout << "The day after " << day << " is "; return "Friday"; } else if ( strcmp( day, "Friday" ) == 0 ) { cout << "The day after " << day << " is "; return "Saturday"; } else if ( strcmp( day, "Saturday" ) == 0 ) { cout << "The day after " << day << " is "; return "Sunday"; } else if ( strcmp( day, "Sunday" ) == 0 ) { cout << "The day after " << day << " is "; return "Monday"; } else { cout << "'" << day << "'"; return " is an invalid day of the week!"; } } const char * DayOfTheWeek::addDays(int addValue) { if ( addValue < 0 ) { if ( strcmp( day, "Monday" ) == 0) { cout << day << " - " << -addValue << " = "; return "Friday"; } else if ( strcmp( day, "Tuesday" ) == 0 ) { cout << day << " - " << -addValue << " = "; return "Saturday"; } else if ( strcmp( day, "Wednesday" ) == 0 ) { cout << day << " - " << -addValue << " = "; return "Sunday"; } else if ( strcmp( day, "Thursday" ) == 0 ) { cout << day << " - " << -addValue << " = "; return "Monday"; } else if ( strcmp( day, "Friday" ) == 0 ) { cout << day << " - " << -addValue << " = "; return "Tuesday"; } else if ( strcmp( day, "Saturday" ) == 0 ) { cout << day << " - " << -addValue << " = "; return "Wednesday"; } else if ( strcmp( day, "Sunday" ) == 0 ) { cout << day << " - " << -addValue << " = "; return "Thursday"; } else { cout << "'" << day << "' "; return "is an invalid day of the week! "; } } else // if our parameter is greater than 0 (positive) { if ( strcmp( day, "Monday" ) == 0) { cout << day << " + " << addValue << " = "; return "Thursday"; } else if ( strcmp( day, "Tuesday" ) == 0 ) { cout << day << " + " << addValue << " = "; return "Friday"; } else if ( strcmp( day, "Wednesday" ) == 0 ) { cout << day << " + " << addValue << " = "; return "Saturday"; } else if ( strcmp( day, "Thursday" ) == 0 ) { cout << day << " + " << addValue << " = "; return "Sunday"; } else if ( strcmp( day, "Friday" ) == 0 ) { cout << day << " + " << addValue << " = "; return "Monday"; } else if ( strcmp( day, "Saturday" ) == 0 ) { cout << day << " + " << addValue << " = "; return "Tuesday"; } else if ( strcmp( day, "Sunday" ) == 0 ) { cout << day << " + " << addValue << " = "; return "Wednesday"; } else { cout << "'" << day << "' "; return "is an invalid day of the week! "; } } } void DayOfTheWeek::printDay() const { cout << "The Value of the " << day; } void DayOfTheWeek::setDay(const char * day) { if (day) {// Here I am allocating the object member char day pointer this->day = new char[strlen(day)+1]; size_t length = strlen(day)+1; // +1 for trailing null char strcpy_s(this->day , length , day); // copying c-strings } else day = NULL; // If their was a problem with the parameter 'day' } DayOfTheWeek::~DayOfTheWeek() { delete day; // Free the memory allocated in SetDay } int main() { DayOfTheWeek MondayObject; // declare an object MondayObject.setDay("Monday"); // Call our public function 'setDay' to set a day of the week MondayObject.printDay(); // Call our public function 'printDay' to print the day we set cout << " object is " << MondayObject.getDay() << endl; // Print the value of the object cout << MondayObject.plusOneDay() << endl; cout << MondayObject.minusOneDay() << endl; cout << MondayObject.addDays(3) << endl; MondayObject.printDay(); cout << " object is still " << MondayObject.getDay() << endl; // Print the value of the object cout << MondayObject.addDays(-3) << endl; return 0; }

    Read the article

  • how to handle duplicates in AVL tree

    - by Ahmed Kotb
    I want to make my avl tree support adding duplicates but there is a problem with the default behavior of the binary search tree with duplicates that the rotation could make nodes with equal key be on the left and the right of the parent for example adding A,A,A will cause the tree to do a rotation to be something like that A / \ A A so getting all the entries with that key will be a problem...and searching in both direction is not something good the solution that i have thought of is making each node stores an array of duplicates so when adding a new item that already exists will be just adding a new item to the array , removing item with key will delete the whole node while the find all items with key will return that array. are there are any other methods to handle duplicates ?

    Read the article

  • jQuery Map Highlight - works fine at DOM ready but failed when loaded by AJAX

    - by Michael Mao
    Hi all: This is uni assignment and I have already done some stuff. Please go to the password protected directory on : my server Enter username "uts" and password "10479475", both without quotes, into the prompt and you shall be able to see the webpage. Basically, if you hover your mouse on top of the contents in worldmap to the upperleft corner, you can see the underneath area is "highlighted" by a gray region and a red border. This is done using one jQuery plugin : at here This part works fine, however, after I use jQuery to load the specific continent map asynchronously, the newly loaded image cannot work correctly. Tested under Firebug, I can see the plugin doesn't "like" the new image cause I cannot find the canvas or other auto-generated stuff which can be founded around the worldmap. All the functionality is done in master.js, I believe you can just download a copy and check the code there. I do hope that I have followed the tutorials on the plugin's doc page, but I just cannot get through the final stage. Code used for worldmap in html: <img id="worldmap" src="./img/world.gif" alt="world.gif" width="398" height="200" class="map" usemap="#worldmap"/> <map name="worldmap"> <area class='continent' href="#" shape="poly" title="North_America" coords="1,39, 40,23, 123,13, 164,17, 159,40, 84,98, 64,111, 29,89" /> </map> Code used for worldmap in master.js //when DOM is ready, do something $(document).ready(function() { $('.map').maphilight(); //call the map highlight main function } On contrast, code used for specific continent map: //helper function to load specific continent map using AJAX function loadContinentMap(continent) { $('#continent-map-wrapper').children().remove(); //remove all children nodes first //inspiration taken from online : http://jqueryfordesigners.com/image-loading/ $('#continent-map-wrapper').append("<div id='loader' class='loading'><div>"); var img = new Image(); // wrap our new image in jQuery, then: // once the image has loaded, execute this code $(img).load(function () { $(this).hide(); // set the image hidden by default // with the holding div #loader, apply: // remove the loading class (so no background spinner), // then insert our image $('#loader').removeClass('loading').append(this); // fade our image in to create a nice effect $(this).fadeIn(); }).error(function () { // if there was an error loading the image, react accordingly // notify the user that the image could not be loaded $('#loader').removeClass('loading').append("<h1><div class='errormsg'>Loading image failed, please try again! If same error persists, please contact webmaster.</div></h1>"); }) //set a series of attributes to the img tag, these are for the map high lighting plugin. .attr('id', continent).attr('alt', '' + continent).attr('width', '576').attr('height', '300') .attr('usemap', '#city_' + continent).attr('class', 'citymap').attr('src', './img/' + continent + '.gif'); // *finally*, set the src attribute of the new image to our image //After image is loaded, apply the map highlighting plugin function again. $('.citymap').maphilight(); $('area.citymap').click(function() { alert($(this).attr('title') + ' is clicked!'); }); } Sorry about the messy code, havn't refactored it yet. I am wondering why the canvas disappers for the continent map. Did I do anything wrong. Any hint is much appreciated and thanks for any suggestion in advance!

    Read the article

  • How to download a file from a server using Java Socket?

    - by Ada
    Hi, I have an assignment about uploading and downloading a file to a server. I managed to do the uploading part using Java Sockets however I am having a hard time doing the downloading part. I should use Range: for downloading parellel. In my request, I should have the Range: header. But I don't understand how I will receive the file with that HTTP GET request. All the examples I have seen was about uploading a file. I already did it. I can upload .exe, image, .pdf, anything and when I download them back (by my browser), there are no errors. Can you help me with the downloading part? Can you give me an example beacuse I really didn't get it.

    Read the article

  • Avoiding RTTI In Java

    - by destructo_gold
    Hi, If I have a superclass, say Animal, and two subclasses: Zebra and Giraffe, If I decide to define a Vector of Animals: Vector <Animal> animals = new Vector(); and I want to say: You can add Giraffes, but you must own at least one Zebra first. What is the best way to do this without using RTTI? (instanceof)

    Read the article

  • trouble with algorithm

    - by rebel_UA
    David likes number of estimates with base "k" and not a multiple(a%2!=0) of the number of zeros at the end. Set system and the number of the order and print it I need to optimi this algoritm: class David{ private: int k; public: David(); David(int); int operator[] (int); }; David::David(){ k=10; }; David::David(int k){ this->k=k; } int David::operator[] (int n){ int q; int p; int i=1; for(int r=0;r<n;i++){ q=0; p=i; for(;;){ if(p%k) break; if(p==0) break; ++q; p/=k; } if(q%2){ r++; } } return i-1; }

    Read the article

  • getline(cin, variable) not wanting to work properly in c++?

    - by Jeff
    Here's my program so far: int main() { char choice = 'D'; string inputString; cout << "Please input a string." << endl; getline(cin, inputString); LetterCount letterCount(inputString); while(choice != 'E') { cout << "Please choose from the following: " << endl << "A) Count the number of vowels in the string." << endl << "B) Count the number of consonants in the string." << endl << "C) Count both the vowels and consonants in the string." << endl << "D) Enter another string." << endl << "E) Exit the program." << endl; cin >> choice; if(choice == 'A' || choice == 'a') { cout << "There are " << letterCount.vowelCount() << " vowels in this string." << endl; } else if(choice == 'B' || choice == 'b') { cout << "There are " << letterCount.consonantCount() << " consonants in this string." << endl; } else if(choice == 'C' || choice == 'c') { cout << "There are " << letterCount.vowelCount() << " vowels and " << letterCount.consonantCount() << " consonants in this string, for a total of " << (letterCount.vowelCount() + letterCount.consonantCount()) << " letters." << endl; } else if(choice == 'D' || choice == 'd') { cout << "Please type in another string." << endl; getline(cin, inputString); letterCount.setInputString(inputString); } else { choice = 'E'; } } } I'm only including the main as it's the issue giver here, everything else functions properly. The problem comes up when I use choice 'D' (input a new string.) as soon as enter is hit, the program returns right to the choice prompt and sets the inputString variable to blank (not the word blank, but nothing in it) the first getline(cin, inputString) works perfectly fine, the second one is the issue giver...any suggestions?

    Read the article

  • how to do this in shell

    - by user150674
    I have a very large file, named 'ColCheckMe', tab-delimited, that you are asked to process. You are told that each line in 'ColCheckMe' has 7 columns, and that the values in the 5th column are integers. Using shell functions indicate how you would verify that these conditions are satisfied in 'ColCheckMe' if In the same file, each value in column 1 is unique. How would I verify that? Also how to write a shell function that counts the number of occurrences of the word “SpecStr” in the file 'ColCheckMe' I tried the first part which checks for the valid number of field and checks the 5th field being integer field. nawk ' NF != 7 { printf("[%d] has invalid [%d] number of fields\n", FNR, NF) } $5 !~ /^[0-9]+$/ { printf("[%d] 5th field is invalid [%s]\n", FNR, $5) }' ColCheckMe now i wanna verify in the same file if the value in column 1 is unique. Also is there a way to write a shell function to count the occurrences of the world "SpecStr" in the file 'ColCheckMe' Thanks a lot

    Read the article

  • Handling aces and finding a segfault in a blackjack program

    - by Bill Adams
    Here's what i have so far... I have yet to figure out how i'm going to handle the 11 / 1 situation with an ace, and when the player chooses an option for hit/stand, i get segfault. HELP!!! #include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #define DECKSIZE 52 #define VALUE 9 #define FACE 4 #define HANDSIZE 26 typedef struct { int value; char* suit; char* name; }Card; typedef struct { int value; char* suit; char* name; }dealerHand; typedef struct { int value; char* suit; char* name; }playerHand; Card cards[DECKSIZE]; dealerHand deal[HANDSIZE]; playerHand dealt[HANDSIZE]; char *faceName[]={"two","three", "four","five","six", "seven","eight","nine", "ten", "jack","queen", "king","ace"}; char *suitName[]={"spades","diamonds","clubs","hearts"}; void printDeck(){ int i; for(i=0;i<DECKSIZE;i++){ printf("%s of %s value = %d\n ",cards[i].name,cards[i].suit,cards[i].value); if((i+1)%13==0 && i!=0) printf("-------------------\n\n"); } } void shuffleDeck(){ srand(time(NULL)); int this; int that; Card temp; int c; for(c=0;c<10000;c++){ //c is the index for number of individual card shuffles should be set to c<10000 or more this=rand()%DECKSIZE; that=rand()%DECKSIZE; temp=cards[this]; cards[this]=cards[that]; cards[that]=temp; } } /*void hitStand(i,y){ // I dumped this because of a segfault i couldn't figure out. int k; printf(" Press 1 to HIT or press 2 to STAND:"); scanf("%d",k); if(k=1){ dealt[y].suit=cards[i].suit; dealt[y].name=cards[i].name; dealt[y].value=cards[i].value; y++; i++; } } */ int main(){ int suitCount=0; int faceCount=0; int i; int x; int y; int d; int p; int k; for(i=0;i<DECKSIZE;i++){ //this for statement builds the deck if(faceCount<9){ cards[i].value=faceCount+2; }else{ //assigns face cards as value 10 cards[i].value=10; } cards[i].suit=suitName[suitCount]; cards[i].name=faceName[faceCount++]; if(faceCount==13){ //this if loop increments suit count once cards[i].value=11; //all faces have been assigned, and also suitCount++; //assigns the ace as 11 faceCount=0; } //end building deck } /*printDeck(); //prints the deck in order shuffleDeck(); //shuffles the deck printDeck(); //prints the deck as shuffled This was used in testing, commented out to keep the deck hidden!*/ shuffleDeck(); x=0; y=0; for(i=0;i<4;i++){ //this for loop deals the first 4 cards, dealt[y].suit=cards[i].suit; //first card to player, second to dealer, dealt[y].name=cards[i].name; //as per standard dealing practice. dealt[y].value=cards[i].value; i++; y++; deal[x].suit=cards[i].suit; deal[x].name=cards[i].name; deal[x].value=cards[i].value; x++; } printf(" Dealer's hand is: %s of %s and XXXX of XXXX. (Second card is hidden!)\n",deal[0].name,deal[0].suit,deal[1].name,deal[1].suit); printf(" Player's hand is: %s of %s and %s of %s.\n",dealt[0].name,dealt[0].suit,dealt[1].name,dealt[1].suit); printf(" the current value of the index i=%d\n",i); //this line gave me the value of i for testing d=deal[0].value+deal[1].value; p=dealt[0].value+dealt[1].value; if(d==21){ printf(" The Dealer has Blackjack! House win!\n"); }else{ if(d>21){ printf(" The dealer is Bust! You win!\n"); }else{ if(d>17){ printf(" Press 1 to HIT or 2 to STAND"); scanf("%d",k); if(k==1){ dealt[y].suit=cards[i].suit; dealt[y].name=cards[i].name; dealt[y].value=cards[i].value; y++; i++; } }else{ if(d<17){ printf(" Dealer Hits!"); deal[x].suit=cards[i].suit; deal[x].name=cards[i].name; deal[x].value=cards[i].value; x++; i++; } } } } return 0; }

    Read the article

  • Displaying an inverted pyramid of asterisks

    - by onyebuoke
    I help in my for my program. I am required 2 create a inverted pyramid of stars which rows depends on the number of stars the user keys, but I've done it so it does not give an inverted pyramid, it gives a regular pyramid. #include <stdio.h> #include <conio.h> void printchars(int no_star, char space); int getNo_of_rows(void); int main(void) { int numrows, rownum; rownum=0; numrows=getNo_of_rows(); for(rownum=0;rownum<=numrows;rownum++) { printchars(numrows-rownum, ' '); printchars((2*rownum-1), '*'); printf("\n"); } _getche(); return 0; } void printchars(int no_star, char space) { int cnt; for(cnt=0;cnt<no_star;cnt++) { printf("%c",space); } } int getNo_of_rows(void) { int no_star; printf("\n Please enter the number of stars you want to print\n"); scanf("%d",&no_star); while(no_star<1) { printf("\n number incorrect, please enter correct number"); scanf("%d",&no_star); } return no_star; }

    Read the article

  • Branch prediction , correlation bit

    - by Maciej Adrzej
    Problem ; Consider following simplified code fragment; if (d==0) d=1; if (d==1) ... Construct the action table for the 1-bit predictor with 1-bit correlation assuming predictor initialized to NOT TAKEN and the correlation bit is initialized to TAKEN. The value of d alternates 1,2,1,2 Note count the instances of misprediction. I tried to solve question my answer is ; |d=?|B1 |B1 |New B1 |B2 |B2 | New B2 | | |Prediction|Action|Prediction|Prediction|Action|Prediction| |1 | NT/NT | T | T/NT | NT/NT | NT | NT/NT | |2 | T/NT | T | T/NT | NT/NT | T | NT/T | |1 | T/NT | T | T/NT | NT/T | NT | NT/NT | |2 | T/NT | T | T/NT | NT/NT | T | NT/T | I doubt whether it is true or not ? Any idea ?

    Read the article

  • IBasic Accumulator

    - by Tara
    I am trying to do an accumulator in IBasic for a college assignment and I have the general stuff down but I cannot get it to accumulate. The code is below. My question is how do I get it to accumulate and pass to the different module. I'm trying to calculate how many right answers the user gets. Also, i need to calculate the percentage of right answers. so if the user gets 9 out of 10 right theyed answer 90% right. 'October 15, 2009 ' 'Lab 7.5 Programming Challenge 1 - Average Test Scores ' 'This is a dice game ' declare main() declare inputName(name:string) declare getAnswer(num1:int, num2:int) declare getResult(num1:int, num2:int, answer:int) declare avgRight(getRight:int) declare printInfo(name:string, getRight:int, averege:float) openconsole main() do:until inkey$<>"" closeconsole end sub main() def name:string def num1, num2, answer, total, getRight:int def averege:float inputName (name) getRight = 0 For counter = 1 to 10 getRight = getAnswer(num1, num2) getRight = getRight + 1 next counter average = avgRight (getRight) printInfo(Name, getRight, average) end sub inputName (name) Input "Please enter your name: " ,name return sub getAnswer(num1, num2) def answer, getRight:int num1 = rnd (10) + 1 num2 = rnd (10) + 1 Print num1, "+ " ,num2 Input "What is the answer to the equation? " ,answer getRight = getResult(num1, num2, answer) return getRight sub getResult(num1, num2, answer) def getRight:int if answer = num1 + num2 getRight = 1 else getRight = 0 endif return getRight sub avgRight(getRight) def average:float average = getRight / 10 return average sub printInfo(name, getRight, averege) Print "The students name is: " ,name Print "The number right is: " ,getRight Print Using ("&##.#&", "The average right is " ,averege * 100, "%") return

    Read the article

  • Diophantine Equation

    - by lakshmi
    Show that it is possible to buy exactly 50, 51, 52, 53, 54, and 55 McNuggets, by finding solutions to the Diophantine equation. You can solve this in your head, using paper and pencil, or writing a program. However you chose to solve this problem, list the combinations of 6, 9 and 20 packs of McNuggets you need to buy in order to get each of the exact amounts. Given that it is possible to buy sets of 50, 51, 52, 53, 54 or 55 McNuggets by combinations of 6, 9 and 20 packs, show that it is possible to buy 56, 57,..., 65 McNuggets. In other words, show how, given solutions for 50-55, one can derive solutions for 56-65.python

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >