TRENDING NEWS

POPULAR NEWS

Help On Fixing My Program

Help on fixing my program?

Edited: There were initialization problems in my code. They are fixed, now.
--------------------------------------
Here is some overhauled code:
http://ideone.com/w9TTyP

The following lines usually guarantee that the program will terminate prematurely:
scanf("%f", mark);
scanf("%d", judges);
They should be:
scanf("%f", &mark);
scanf("%d", &judges);
There are other problems and other information scanf provides. I packed these information into the added functions get_int and get_double.

I hoped that through introduction of two above functions the code and main logic would be easier to read. Additionally the program will terminate in case you enter the value 0 for judges ...

Have fun.

Need help fixing my C++ program.?

This is my problem, and my faulty solution is attached bellow.
Write a predicate function

bool same_set(vector a, vector b)

that checks whether two vectors have the same elements in some order, ignoring multiplicities. For example, the two vectors

1 4 9 16 9 7 4 9 11
and

11 11 7 9 16 4 1

would be considered identical. You will probably need one or more helper functions.



#include
#include

using namespace std;



bool same_set(vector a, vector b)
{
int i = 0;
int j = 0;

for (i = 0; i< a.size(); i++)
{
for (j = 0; j < b.size(); j++)
{
if (a[i] == b[j])
{
return true;
break;
}
}
}
}

int main()
{
vector a(9);
a[0] = 1;
a[1] = 4;
a[2] = 9;
a[3] = 16;
a[4] = 9;
a[5] = 7;
a[6] = 4;
a[7] = 9;
a[8] = 11;

vector b(7);
b[0] = 11;
b[1] = 11;
b[2] = 7;
b[3] = 1;
b[4] = 14;
b[5] = 4;
b[6] = 6;


cout << "Vectors a an

How do you fix this program in c++?

The process of finding the largest number (i.e., the maximum of a group of numbers) is used frequently in computer applications. For example, a program that determines the winner of a sales contest inputs the number of units sold by each salesperson. The salesperson who sells the most units wins the contest. Write a pseudocode program, then a C++ program that uses a while statement to determine and print the largest number of 10 numbers input by the user and the smallest number. Your program should use three variables, as follows:

counter:


A counter to count to 10 (i.e., to keep track of how many numbers have been input and to determine when all 10 numbers have been processed).

number:


The current number input to the program.

largest:


The largest number found so far.

so far I have this:


#include

using std::cout;
using std::cin;
using std::endl;

//function main begins program execution

int main()
{
int counter;
int number;
int largest;
int smallest;

counter=0;
largest=0;
smallest=0;


cout<<" ENTER 10 NUMBERS"<
while (counter<10)
{
cin>>number;
if (largest {

largest=number;
}
else
if (smallest

smallest=number;

counter= counter + 1;

}
cout<<"THANK YOU\n\n"< cout<<"THE LARGEST NUMBER IS: "< cout<<"THE SMALLEST NUMBER IS: "< return 0;

}
this is just not working.please help

Java programming help , How can I fix the problem in my code ?

hello , i'v been trying to do one of my assignments according to these instructions

Money deposited in a bank savings account grows by accruing interest. If P dollars is deposited at the beginning of a year, then the amount in the account after n years can be calculated using the following formula: S = P * ( 1 + i )n, where i = annual interest rate ( e.g., 5% = .05), and S = amount in the account after n years. Write a program that prompts the user for P, i, and n, and calculates and displays S. You must use a programmer-defined class method for performing the calculation and you must use a built-in Java Math class method for calculating the compounding formula. You must prompt for input using the Input class methods that are provided as a download for this unit.



my instructor told me that I didn't use a separate method for the financial calculation

here's the code ..

public class U7_Assignment_2
{

public static void main(String[] args)
{

Scanner Input = new Scanner(System.in) ;

double Dollars ,years,annualRate,AmountInAcc;


System.out.println(" Please enter the number of dollars ");
Dollars = Input.nextDouble();

System.out.println(" Please enter the number of years ");
years = Input.nextDouble();

System.out.println(" Please enter the annual interest rate ");
annualRate= Input.nextDouble();

// S = P * ( 1 + i )n is basically (Dollars*(1 + annualRate )*Math.sqrt( years ))

AmountInAcc = (Dollars*(1 + annualRate )*Math.sqrt( years ));

System.out.println("the amount of money in the account is "+ AmountInAcc);
}
}

Can you guys help me fix this programming problem?

here is a dice game that I wrote in javascript:

http://spottedmarley.com/craps

Help me fix my java program? Output smallest and second smallest number using terminating number?

Ask the user for the following information, in this order:

1. A terminating value (real number). The user will enter this value again later, to indicate that he or she is finished providing input.
2. A sequence of real numbers. Keep asking for numbers until the terminating value is entered.
Compute and output the smallest and second-smallest real number, in that order. It is possible for the smallest and second-smallest numbers to be the same (if the sequence contains duplicate numbers).

Example:

java TwoSmallest

123 [this is the terminating value, not part of the set of numbers]
17
23.5
10
15.2
30
8
16
123 [this is the terminating value again, indicating that the user is done]

RESULT: 8.0
RESULT: 10.0
-----
this is the program that i have written so far


public class TwoSmallest {
public static void main(String [] args){

System.out.println("Enter a terminating value: ");
double terminator = IO.readDouble();

double firstsmallest = 0;
double secondsmallest = 0;


System.out.println("Enter a number");
double num = IO.readDouble();

firstsmallest=num;

for (num=0; num!=terminator;)

if ( num < firstsmallest)
{
firstsmallest = num;

}else {
if ( num < secondsmallest)
{
secondsmallest = num;

}
}


System.out.println(firstsmallest);
System.out.println(secondsmallest);

}


}

i'm having difficulty getting the program to recognize the terminating sequence and therefore it can't output the small and smallest numbers. can anyone help?

How can I fix my slow laptop without downloading programs? I run Windows 7 on an Acer laptop.

If you can stand it, back up all the data, erase the drive, and reinstall the OS fresh, including all the patches.  That fixes a lot of malware issues, broken configurations, and oddball installs.  It also takes a lot of time and is a big pain. See if you are using all the RAM.  In the Task Manager "Performance" tab, see how much physical memory is free.  Your "commit charge" should not be much larger than the amount of installed memory. Adding physical memory is a common way to fix slow PC.Make sure the hard drive is healthy.  A slow PC can be a sign of a failing hard drive.  Unfortunately, you will need to download software for that.  I like the free SpeedFan.  Replacing the drive with a faster one or an SSD could help.Make sure the CPU is not overheating.  CPU-Z will show the CPU clock speed.  If it keeps low, check the power profile, or look for clogged cooling ports.Uninstall all software that you don't use.Scan for Malware with two or three programs, like Microsoft Security Essentials and MalwareBytes Pro.Empty overflowing TEMP directories and Windows Prefetch files.  Ccleaner is a program which will do this automatically for you.

TRENDING NEWS