Using system(cls) to clear only a part of the screen?

Hello forum, first off excuse my bad english I will try to explain my problem the best as I can and thank you very much for your help.

In this program I need to take some data from 10 customers, 1 by 1 you enter the info of each customer then it will clear the screen and show the results of it.

I think you will understand better if you see these pictures:

http://i.imgur.com/Zv2Jf.png

http://i.imgur.com/Ebmce.png

http://i.imgur.com/409id.png

http://i.imgur.com/5gC8U.png

If you see at the last one it clears all the screen deleting customer 1 results, I want it to only clear the info you typed about customer 2, show costumer 2 results but keeping customer 1 results, till it gets to customer 10.

I'm not sure if to do this you need to use another command instead of system ("cls")

If you didn't understand something just tell me :)

Heres my program code.. also I'm using dev c++

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <iomanip>
#include <conio.h>

using namespace std;

main()
{
      string fac, nom, ape;
      float mont, total, desc;
      int customer;
      cout<<fixed;
      cout<<setprecision(2);
      
      for (customer=1; customer<11; customer++)
      {
          {start:
          cout<<"Customer "<<customer<<endl<<endl;
          cout<<"Bill number: ";
          cin>>fac;
          cout<<"Name: ";
          cin>>nom;
          cout<<"Last name: ";
          cin>>ape;
          cout<<"Purchase amount: ";
          cin>>mont;
          cout<<endl<<endl;
          system("cls");
          }
      if (mont<=100)
      {
                    desc=mont*0.15;
                    total=mont-desc;
                    }
      if ((mont>100) && (mont<=250))
      {
                      desc=mont*0.25;
                      total=mont-desc;
                      }
      if (mont>250)
      {
                   desc=mont*0.35;
                   total=mont-desc;
                   }
      cout<<"Customer "<<customer<<endl<<endl;              
      cout<<"Name: "<<nom<<endl;
      cout<<"Last name: "<<ape<<endl;
      cout<<"Purchase amount: "<<mont<<endl;
      cout<<"Discount: "<<desc<<endl;
      cout<<"Total: "<<total<<endl;     
      cout<<endl<<endl;
      }
      }
why not when you clear the screen just reprint the customer one data
Sounds good but could you give me a hand with that?
sure give me ten mins
sorry I'm actually going to have to do this in the morning
It's Ok I will check tomorrow then, thank you for helping
hey what does the variable desc represent?

edit: nvr mnd i figured it out
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <string>
#include <conio.h>

using namespace std;

int main()
{
    string billNumber[10], name[10], lastName[10];
    float purchaseAmount[10], total[10], discount[10];
    int customer, customerCount;
    
    for (customer=1; customer<11; customer++)
    {
        cout<<"Customer " << customer << endl << endl;
        cout<<"Bill number: ";
        cin>> billNumber[customer-1];
        cout<<"Name: ";
        cin>> name[customer-1];
        cout<<"Last name: ";
        cin>> lastName[customer-1];
        cout<<"Purchase amount: ";
        cin>> purchaseAmount[customer-1];
        cout<<endl<<endl;
        system("cls");
    
        if (purchaseAmount[customer-1] <= 100)
        {
            discount[customer-1]=purchaseAmount[customer-1]*0.15;
            total[customer-1]=purchaseAmount[customer-1]-discount[customer-1];
        }
    
        else if ((purchaseAmount[customer-1]>100) && (purchaseAmount[customer-1]<=250))
        {
            discount[customer-1]=purchaseAmount[customer-1]*0.25;
            total[customer-1]=purchaseAmount[customer-1]-discount[customer-1];
        }
    
        else if (purchaseAmount[customer-1]>250)
        {
            discount[customer-1]=purchaseAmount[customer-1]*0.35;
            total[customer-1]=purchaseAmount[customer-1]-discount[customer-1];
        }
        
        customerCount=1;
        
        for(;customerCount<=customer;customerCount++)
        {
            cout<<"Customer "<< customerCount << endl << endl;
            cout<<"Name: "<< name << endl;
            cout<<"Last name: "<< lastName << endl;
            cout<<"Purchase amount: "<< purchaseAmount << endl;
            cout<<"Discount: "<< discount << endl;
            cout<<"Total: "<< total << endl;
            cout<< endl << endl;
        }
    }
}
Last edited on
Sorry for the late answer and thank you for the code it fixed the issue but now it doesn't show the results properly what can it be? also if you could, could you link me to any website that explains the use of strings detailed for a begginer? because some of your code confuses me like (customer/discount-1) and the [10] things.

http://i.imgur.com/AlapY.png


Last edited on
Ohhh I guess the [10] means the amout of these values stored and the customer-1 means it's taking out 1 right.... or am I wrong?
Last edited on
A string is actually a data type. The [10] is creating an array with a size of 10. Putting it all together, you have arrays billNumber, name, and lastName what can contain 10 strings. The [] symbols you see later on is the [] operator, or for arrays, the index operator.

When using an array (of any type) the index's start at 0 and go until n-1 where n is the size of the array. That is why customer - 1 is there.
Oh I see thanks for making it clear :)
Topic archived. No new replies allowed.