I am trying to get the User to enter values into the array. 20 numbers, and the array has 2 columns. 1 colum for the value[x] entered and another with the [y]. Y should be the number with added VAT (30%). can anyone help?
#include <iostream>
usingnamespace std;
int main()
{
int PriceArray[20] [2] = { {}, {} };
int x, y;
int Num, Vat, Sum;
int counter;
cout << "Please Enter 20 Prices and I will add VAT to it(30%). \n";
for (x = 0; x < 20; x++){
cin >> x;
for (y = 0; y < 2; y++){
cin >> y;
}
}
cout << PriceArray [x] [y];
return 0;
}
You're confusing your loop index variables with the values being entered.
x and y loop indexes and should be ints.
Line 17 enters the price directly into the array.
Line 18 calculates the prince + VAT.
Line 23, you want to output the calculated prices rather than input them.
Thank you for the information. I get 3 errors on lines I dont even have?
||=== Build: Debug in NumVAT (compiler: GNU GCC Compiler) ===|
C:\Users\Joshyma\Desktop\C++\NumVAT\main.cpp|30|error: 'cout' does not name a type|
C:\Users\Joshyma\Desktop\C++\NumVAT\main.cpp|31|error: expected unqualified-id before 'return'|
C:\Users\Joshyma\Desktop\C++\NumVAT\main.cpp|32|error: expected declaration before '}' token|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Semi pseudo:
For(x stuff; limit 10)
{
----get the value from user and store it into array[x][0]
----modify value at array[x][1] = array[x][0]*1.3;
----For(y stuff; limit 2)
----{
--------print value at array[x][y];(ideally twice) //<<---------Your mistake here.
----}
}