Final Project Concept

--Originally published at how not to program

For the final project, my team and I decided to develop a program that can help you to find out your average grade for all your courses. We also want to add a prediction mode that calculates how much do you need in your final partial so you don’t fail.

Right now we´re just drafting the main funtions the program needs in order to accomplish everything

¿Cuál semestre estás cursando? = nsemestre
¿En qué parcial estás? = nparical
¿Cuántas materias cursas? = nmaterias

//Inicio Loop^(nmaterias)
¿Cuál es el porcentaje por parcial de materia1? %parcial1

materia1,calficacionparcial1 x %parcial1

We´ll work on the program via GitHub and we’ll update with more news of the project in the following weeks.

If you have any idea feel free to comment


Sum of numbers

--Originally published at how not to program

 

In this program, we asked the user for a range of numbers and the program sum the numbers in between.

Captura1.PNGCaptura2.PNG

If you want to make improvements or modifications, here is the code for you to copy and paste it anywhere.

#include <iostream>
#include <cmath>
using namespace std;
int sumanumeros(int a, int b){
int suma,contador;
suma=0;
contador=a;
if(a>b){
cout<<“The first number must be smaller than the second”<<endl;
return 0;
} else{
if(a==b){
cout<<“There is no range between the numbers”<<endl;
return 0;
} else{
do{
sum=sum+counter;
counter++;
}while(counter<=b);
return sum;
}
}
}
int main(){
int min,max,result;
cout <<“Type in two numbers to obtain the sum of their range”<<endl;
cout <<“First number”;
cin >> x>> endl;
cout<<“Second number”<<;
cin>> max;
cout<<endl;
result= sumanumeros(min,max);
if(result>0);{
cout<<“Result “<<result<<endl;
}
return 0;
}


Random number

--Originally published at how not to program

In this program, we use the random number function to make the user guess a number between 1 and 100.

captura q.PNGCaptura2.PNG

 

If you want to make improvements or modifications, here is the code for you to copy and paste it anywhere.

# include <iostream>
# include <cmath>
# include <cstdlib>
using namespace std;
int randomnumber (){
int random;
random = rand()%100+1;
return random;
}
void hints (int number, int random){
if (number==random){
cout <<“You did it!!”<<endl;
}
else{
if(number<random){
cout<< “Too low”<<endl;
}
else if (number> random){
cout<< “Too high”<<endl;
}
else if(number<0 && numus>100){
cout << “Try whole numbers between 1 and 100″<<endl;
}
}
}
int main (){
int num, secret, counter=0;
char op;
cout<<“You must guess a number between 1 and 100″<<endl;
secret=randomnumber();
counter = 0;
do{
if (counter==0) {
cout<<“Guess the number”<<endl;
}
else {
cout<<“Guess again”<<endl;
}
cin>> num;
hints(num,secret);
contador++;
} while (num!= secret);
cout<<“You used “<<counter<<” tries”<<endl;
}

 


Quiz week 8

--Originally published at how not to program

In this quiz, we have to calculate wich is the number of the fibonacci series.

Captura.PNG

If you want to make improvements or modifications, here is the code for you to copy and paste it anywhere.

#include <iostream>
using namespace std;

int fibonacci(int n){
int answer, n;
if (n==0 || n==1){
answer=0;
} else {
answer = fibonacci(n-1) + fibonacci(n-2);
}
return answer;
}

int main(){
fibonacci(n)
cin >>n>> endl;
x = fibonacci(n);
cout <<x<< endl;
return 0;
}


QUIZ WEEK 9

--Originally published at how not to program

In this program we have to measure the distance between to coordinates. first we research for the function, wich, according to Math Warehouse, is:

 

You can read more about the distance between coordinates at http://www.mathwarehouse.com/algebra/distance_formula/index.php

 

If you want to make improvements or modifications, here is the code for you to copy and paste it anywhere.

#include <iostream>
using namespace std;

double distance (double x1,double x2,double y1,double y2)
{
double d=sqrt( pow(x2-x1,2) + pow(y2-y1,2) );
return d;
}
int main ()
{
double x1, x2, y1, y2;
cout << “Please input the values for x and y of the first coordinate” << endl;
cin >> x1;
cin >> y1;

cout << “Please input the values for x and y of the second coordinate” << endl;
cin >> x2;
cin >> y2;

double d = distance (x1, x2, y1, y2);

return d;
}


Quiz Week 4

--Originally published at how not to program

This program asks for three numbers and prints the minimum and the sum of their squares.

 

If you want to make improvements or modifications, here is the code for you to copy and paste it anywhere.

 

#include <iostream>
#include <cmath>
using namespace std;
int x,y,z,sumacuadrados,minimo;

int minimumThree (){

if (x<y||x<z) {
minimo= x;
}
else {
if (y<x || y<z ){
minimo =y ;
}
else {
minimo = z;
}
}

return minimo;
}

int sumSquares(){

sumacuadrados =pow(x,2)+pow(y,2)+pow(z,2);
return sumacuadrados;
}

int main (){
cout << “Type in any number” << endl;
cin >> x;
cout << “Type in any number” << endl;
cin >> y;
cout << “Type in any number” << endl;
cin >> z;

minimumThree();
sumSquares();

cout << “The minimum number is” << minimo <<endl;
cout << “The square sum is “<< sumacuadrados<< endl;
return 0;
}


Temperature

--Originally published at how not to program

This code converts Fahrenheit degrees to Celsius and tells you if at that temperature the water boils or not.wsq02

If you want to make improvements or modifications, here is the code for you to copy and paste it anywhere.

#include <iostream>
using namespace std;

int dgf, dgc;

int main (){
cout <<“Type in degrees in Farenheit”<< endl;
cin >> dgf;
dgc= 5*(dgf-32)/9;

if (dgc>=100) {
cout << dgf <<” degrees Farenheit are “<< dgc <<” degrees in Celsius”<< endl;
cout << “Water usually boils at this temperature”<<endl;
}
else {
cout << dgf <<” degrees Farenheit are “<< dgc <<” degrees in Celsius”<< endl;
cout << “Water usually not boils at this temperature”<< endl;
}
return 0;
}


Fun With Numbers

--Originally published at how not to program

For this activity, we should ask the user for two numbers and display the following results:

  • The sum of the two numbers.
  • The difference of the two numbers.
  • The product of the two numbers.
  • The integer based division of the two numbers (so no decimal point). First divided by second.
  • The remainder of integer division of the two numbers.

 

captura4 captura5 captura6

 

If you want to make improvements or modifications, here is the code for you to copy and paste it anywhere.

#include <iostream>
using namespace std;

double sum, diff, prod, rem;
int div;

int main (){
int a;
cout<<“Type in one number”<<endl;
cin >> a;
int b;
cout <<“Type another number”<<endl;
cin >> b;

sum=a+b;

diff=a-b;

prod=a*b;

rem=a/b;

div=a%b;

cout <<“Sum is “<< sum <<endl;

cout <<“Difference is “<< diff <<endl;

cout <<“Product is “<< prod <<endl;

cout <<“Remainder is “<< rem <<endl;

cout <<“Division is “<< div <<endl;

return 0;
}

 


Quiz Week 3

--Originally published at how not to program

In this quiz the user should input a number and if the input is a positive number the code should gave him the square root and cubic root of the number, but if the number is negative only the cubic rot shall be displayed.
}qw3

If you want to make improvements or modifications, here is the code for you to copy and paste it anywhere.

#include <iostream>
using namespace std;
#include <cmath>
int x,s,c;
int main(){
cout <<“Type in a number”<<endl;
cin >>x;
s=sqrt(x);
c=cbrt(x);
if(x>0){
cout <<“The square root is “<< s <<endl;
cout <<“The cubic root is “<< c <<endl;
}
else
cout <<“The cubic root is “<< c <<endl;
return 0;