martes, 6 de mayo de 2014

Multidimensional Arreys

Multidimensional Arreys aren't so easy to understand, the book define it like an array inside another array. Two dimensional arrey is like a table, rows times columns. I will show you a very basic code to help understand a two dimensional arrey.


#include<iostream>
using namespace std;

int main(){

int arrey[2][3]= {{1,2,3},{4,5,6}};

//the first braces[2] are the number of rows
//the second one[3] is the number of columns
for(int row=0; row< 2; row++){//This for loop is to print out the 2 rows (1 2 3)
                                                                                                      //(4 5 6)
for(int column=0; column < 3; column++){ //An this to print out the columns |1| ,|2|,|3|
                                                                                                          //  |4|, |5|,|6|

cout << arrey[row][column] << " "; //prints out the array
}
cout<<endl;
}
system("pause");
return 0;
}



Is not a great code but it's something to have an idea of how a multidimensional arrey works

domingo, 27 de abril de 2014

work-study helpful program

As a student who is in the work-study program of the university, I constantly have to compute my  remaining hours of work, the salary, time to complete the hours and  divide  my study time with the work time.
I made a personal program that computes the remaining hours, total salary, days left for work and hours per day to complete the assigned hours in the semester. It could be very useful for those who are in the work-study program




#include<iostream>
#include<stdlib.h>
#include<cmath>
using namespace std;
int main(){
double assigned_hours, hours_worked, spare_hours;
double total_salary_assigned,spare_salary, div_hours;
const double minimum_wage=7.25;
int days_left;
char opt;
do{
cout << "This program helps you to organize the college's work-study program of a student\n";
cout << "with a minimum wage of $7.25 per hour\n\n";
cout << "Enter the hours assigned for work\n";
cin >> assigned_hours;
if(assigned_hours <= 0){
cout << "Not a valid input\n";
system("pause");
exit(1);
}
cout << "Now enter the hours that you have worked\n";
cin >> hours_worked;
if(hours_worked > assigned_hours){
cout << "You have completed all the hours\n";
system("pause");
exit(1);
}
else if(hours_worked < 0){
cout << "Not a valid input\n";
system("pause");
exit(1);
}
total_salary_assigned= minimum_wage*assigned_hours;
spare_hours = assigned_hours-hours_worked;
spare_salary = spare_hours*minimum_wage;
cout<< "How many days you got to finish the hours?\n";
cin >> days_left;
if(days_left <= 0){
cout << "You have no days left to complete the remainig hours\n";
system("pause");
exit(1);
}

div_hours = floor(spare_hours/days_left);
cout<< "Your total salary assigned is: $" << total_salary_assigned << endl;
cout << "You have " << spare_hours << " hours to work in " <<days_left << " days\n";
cout << "A total of $" << spare_salary << " is what remains of the inicial salary assigned\n";
cout << "You can work a minimum of "<< div_hours << " hour(s) a day to complete the remaning hours\n";
cout << "Do you want to calculate another? press 'y' if yes else press any key\n";
cin >> opt;
}while(opt == 'y' || opt == 'Y');

return 0;


}

jueves, 6 de marzo de 2014

Bad luck?

Yesterday (5/03/2014) was the first midterm of the class, I'm always in space or something because I didn't know that we had to do the exam with PEN only, no pencil. I have no pens! but I search for one on my backpack  and lucky me! I found something that  once was a pen. It was the piece of plastic that  goes inside a pen so, I did the whole exam with that. I felt  I did that first midterm in hardcore mode.

Today, I was doing this Blog, and I received a feedback from the Professor telling me that he needed the .cpp files of the second lab. I didn't know we had to submit the .cpp files  with the labs!I'm always in space >:/. Anyway, I had to search for all the 5 problems  of the second lab, and the other 6 of the third one to edit the submissions of both labs and probably he will deduct point for late submission even we(me and my partner) submitted on time.


I did the exam using this piece of...pen!:


Robotiky

Robotiky its a wonderful toy for people with zero knowledge of programming , Robotiky is similar to Lego Mindstorms, made up of handful of components, including wheel, a microprocessor, a battery pack, light sensors and a line following sensor, just like the Lego Mindstorms. It's a great source to teach children to programming. The concept is simple the toy is connected to a computer and trough a program you drag and drop commands like, move forward or turn left or right. It is a fun way to learn the basics of progamming.  Here's the article if you want to learn more about Robotiky : http://www.wired.co.uk/news/archive/2014-03/06/robotiky

This article reminds me my first year of college when I had to create and  program a Lego Mindstorms toy, it was a good experience to start knowing the programming world. 


We named it Beethoven.



First Blog!



#include<iostream>
using namespace std;
 
 
int main(){
 
 
int Number_blog;
 
 
cout << " Enter the number of blogs you have posted\n";
cin >> Number_blog;
 
 
if (Number_blog == 1){
 
 
cout << "Correct!\n";
}
else{
cout << "Incorrect\n";
}
system("pause");
return 0;
}