Форум программистов, компьютерный форум, киберфорум
C# для начинающих
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.82/11: Рейтинг темы: голосов - 11, средняя оценка - 4.82
0 / 0 / 0
Регистрация: 17.03.2012
Сообщений: 7

Банковская программа, исправить код

04.04.2012, 06:23. Показов 2190. Ответов 4
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
преподователь задал написать задачу которая будет выполнять функции банка ,сделал но выдаёт ошибки мог бы кто их исправить а то идеё нету
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication1
{
    public class CITIBANK
    {
 
        //global variable for the length of 
 
        public static int atm_card_verif;
        public static int pin_verif;
        public static int choice;
        public static int account1;
        public static decimal deposit1;
        public static decimal withdrawal1;
        public static int size_account;
        //  public static int longer; //
 
 
 
        // class for user file
        public static void userfilearray(int[][] array)
        {
            string first_name;
            string last_name;
            string adresse;
            int pwd;
            int atm_card;
            int account;
            decimal deposit;
            int size_user = 0;
 
            size_user = array.Length; //size of the array to pass by parameter
            //  if (longer == 0 )
            size_user += 1;
            if ((atm_card_verif == 0000) && (pin_verif == 0000))
            {
                Console.WriteLine("Enter the client first name:");
                first_name = Convert.ToString(Console.ReadLine());
                array[size_user][ 1] = first_name;
                //check for presence of data
                Console.WriteLine("Enter the client last name:");
                last_name = Convert.ToString(Console.ReadLine());
                array[size_user][ 2] = last_name;
                //
                Console.WriteLine("Enter the client Adresse:");
                adresse = Convert.ToString(Console.ReadLine());
                array[size_user][ 3] = adresse;
                //
                Console.WriteLine("Allow the client to type his password on 4 digits:");
                pwd = Convert.ToInt32(Console.ReadLine());
                array[size_user][ 4] = pwd;
                //
                Console.WriteLine("Enter the client ATM_card number on 4 digits:");
                atm_card = Convert.ToInt32(Console.ReadLine());
                array[size_user][ 5] = atm_card;
                //
                Console.WriteLine("Create an Bank Account for the client:");
                account = Convert.ToInt32(Console.ReadLine());
                array[size_user][ 6] = account;
                //
                Console.WriteLine("Type the Deposit amount:");
                deposit = Convert.ToDecimal(Console.ReadLine());
                array[size_user][ 7] = deposit;
            }
            else
            {
                for (int row = 0; row < size_user; row++)
                {
                    if ((array[row][ 4] == pin_verif) && (array[row][ 5] == atm_card_verif))
                    {
                        account1 = array[row][ 6];
                        deposit1 = array[row][ 7];
                        Console.WriteLine("Welcome once again to your bank, choice your operation");
                        break;
                    }
                    else
                        Console.WriteLine("Sorry, this client is not identify by citibank, contact your administrator");
 
                }
 
            }
        }
 
 
        //class for user account file
        public static void accountfilearray(int[][] array)
        {
            int account;
            //  int routine_number;
            //  decimal debit_amount;
            decimal credit_amount;
            // decimal balance;
            // decimal withdrawal;
            size_account = array.Length; // measure the size of the array to pass by parameter
            //  longer2 += 1;
 
            Console.WriteLine(" ");
            Console.WriteLine("Choose the operation to do");
            Console.WriteLine("\n");
            Console.WriteLine(" 1- Make a Withdrawal");
            Console.WriteLine("\n");
            Console.WriteLine(" 2- Make a deposit");
            Console.WriteLine("\n");
            Console.WriteLine(" check your account balance:");
            choice = Convert.ToInt32(Console.ReadLine());
            account = account1; //retrieve the account number;
            credit_amount = deposit1; //retrieve the amount in the account;
 
 
            if (choice == 1) // for withdrawal operation
            {
                Console.WriteLine("Enter the amount to withdrawal:");
                withdrawal1 = Convert.ToDecimal(Console.ReadLine());
                if (withdrawal1 > deposit1)
                    Console.WriteLine("Sorry this operation is not allow");
                else
                {
                    // Writing in the file account
                    credit_amount = credit_amount - withdrawal1;
                    for (int row = 0; row < size_account; row++)
                    {
                        if (array[row][ 1] == account)
                        {
                            array[row][ 2] = credit_amount;
                            break;
                        }
                        else
                        { // create the new record in the array
                            array[size_account + 1][ 1] = account;
                            array[size_account + 1][ 2] = credit_amount;
                        }
 
                    }
 
 
                }
 
 
            }
 
            if (choice == 2) // for deposit operation
            {
 
                Console.WriteLine("Enter the amount to withdrawal:");
                withdrawal1 = Convert.ToDecimal(Console.ReadLine());
 
                credit_amount = credit_amount + withdrawal1;
                for (int row = 0; row < size_account; row++)
                {
                    if (array[row][ 1] == account)
                    {
                        array[row][ 2] = credit_amount;
                        break;
                    }
                    else
                    { // create the new record in the array
                        array[size_account + 1][ 1] = account;
                        array[size_account + 1][ 2] = credit_amount;
                    }
 
                }
            }
 
 
 
        }
 
        // class for any bank transaction
 
        public static void transactfilearray(int[][] array)
        {
            int size_transact;
            size_transact = array.Length; // measure the size of the array to pass by parameter
          
 
        }
 
 
 
 
        static void Main(string[] args)
        {
            // int atm_card; // the ATM card number
            // int pin; //pin number or password
            //int choice; // the number of the operation
            int i = 0;
            // int pin_verif; // for verification at connection to the account
            // int atm_card_verif; //for verification at connection to the account
 
            //
            // Declare the array of two elements(i rows )
 
            int[][] userfile = new int[i][]; //jagged array for user file
            int[][] accountfile = new int[i][]; //jagged array for account file
            int[][] transactionfile = new int[i][]; //jagged array for all transaction file
 
 
            // longer = userfile.Length; //check for the array elements of user file
            // longer2= accountfile.Length; //check for the array elements of account file
            //  longer3 = transactionfile.Length; //check for the array elements of transaction file
 
 
            Console.WriteLine("Welcome to CITIBANK");
            Console.WriteLine("\n");
            //client insert his card;
            Console.WriteLine("Insert your ATM CARD by typing 4 digits:");
            atm_card_verif = Convert.ToInt32(Console.ReadLine());
            //client type is password
            Console.WriteLine("Enter you PIN number by typing 4 digits:");
            pin_verif = Convert.ToInt32(Console.ReadLine());
 
            if ((atm_card_verif == 0000) && (pin_verif == 0000)) //if administrator loggin
            {
                Console.WriteLine("Choose the operation to do");
                Console.WriteLine("\n");
                Console.WriteLine(" 1- Create an account for a new client");
                Console.WriteLine("\n");
                Console.WriteLine(" 2- Close a client account");
                Console.WriteLine("\n");
                Console.WriteLine(" Choose the number of the operation to execute:");
                choice = Convert.ToInt32(Console.ReadLine());
                if (choice == 1) // to open an account for client
                    // Console.WriteLine(" ");
                    userfilearray(userfile);
 
                else
                    if (choice == 2) // to close the client account
                        Console.WriteLine(" ");
 
 
 
                    else
                        Console.WriteLine("this operation doesn't exist in this system");
 
 
            }
            else   //if user connected
            {
 
                userfilearray(userfile);
                accountfilearray(accountfile);
 
 
 
                //Now run the For on userfile to verify the user account and pin validate.
 
            }
 
        } // end of Main Avoid
 
    }
}
0
IT_Exp
Эксперт
34794 / 4073 / 2104
Регистрация: 17.06.2006
Сообщений: 32,602
Блог
04.04.2012, 06:23
Ответы с готовыми решениями:

Программа по замене символов, исправить код
Написал такую вот программку... не судите сильно строго я только учусь! Добавлено через 1 минуту using System; using...

Банковская программа
Пользователь вводит сумму вклада и процент, который будет начисляться ежегодно. Отобразить размер вклада поочередно на ближайшие 5 лет.

Базовая банковская программа с доступом к примитивной БД
]Если кому не сложно, тыкните носом в какулю, а то я не нахожу ошибку. Приблизительно сразу в начале :( Есть ощущение что fstream не...

4
Банальное исключение
 Аватар для WorldException
127 / 95 / 12
Регистрация: 31.03.2010
Сообщений: 314
Записей в блоге: 1
04.04.2012, 06:42
А что за ошибки выдаёт, мы гадать должны?
0
0 / 0 / 0
Регистрация: 17.03.2012
Сообщений: 7
04.04.2012, 07:21  [ТС]
Содержание ошибки
Error 1 Cannot implicitly convert type 'string' to 'int' C:\Users\Kozitski\Desktop\ConsoleApplica tion1\ConsoleApplication1\Program.cs 43 40 ConsoleApplication1
Error 2 Cannot implicitly convert type 'string' to 'int' C:\Users\Kozitski\Desktop\ConsoleApplica tion1\ConsoleApplication1\Program.cs 47 40 ConsoleApplication1
Error 3 Cannot implicitly convert type 'string' to 'int' C:\Users\Kozitski\Desktop\ConsoleApplica tion1\ConsoleApplication1\Program.cs 51 40 ConsoleApplication1
Error 4 Cannot implicitly convert type 'decimal' to 'int'. An explicit conversion exists (are you missing a cast?) C:\Users\Kozitski\Desktop\ConsoleApplica tion1\ConsoleApplication1\Program.cs 67 40 ConsoleApplication1
Error 5 Cannot implicitly convert type 'decimal' to 'int'. An explicit conversion exists (are you missing a cast?) C:\Users\Kozitski\Desktop\ConsoleApplica tion1\ConsoleApplication1\Program.cs 128 46 ConsoleApplication1
Error 6 Cannot implicitly convert type 'decimal' to 'int'. An explicit conversion exists (are you missing a cast?) C:\Users\Kozitski\Desktop\ConsoleApplica tion1\ConsoleApplication1\Program.cs 134 59 ConsoleApplication1
Error 7 Cannot implicitly convert type 'decimal' to 'int'. An explicit conversion exists (are you missing a cast?) C:\Users\Kozitski\Desktop\ConsoleApplica tion1\ConsoleApplication1\Program.cs 156 42 ConsoleApplication1
Error 8 Cannot implicitly convert type 'decimal' to 'int'. An explicit conversion exists (are you missing a cast?) C:\Users\Kozitski\Desktop\ConsoleApplica tion1\ConsoleApplication1\Program.cs 162 55 ConsoleApplication1

_______
0
20 / 19 / 0
Регистрация: 04.04.2012
Сообщений: 31
04.04.2012, 07:49
Почитайте про преобразования типов. Компилятор ругается, что вы сначала string пытаетесь привести к int, а потом - decimal. Смотрите в сторону Convert.ToInt32()
0
 Аватар для buntar
543 / 544 / 181
Регистрация: 16.03.2012
Сообщений: 1,160
Записей в блоге: 2
04.04.2012, 12:37
Цитата Сообщение от Aexx Посмотреть сообщение
Почитайте про преобразования типов. Компилятор ругается, что вы сначала string пытаетесь привести к int, а потом - decimal. Смотрите в сторону Convert.ToInt32()
или использовать Int32.Parse();

Добавлено через 2 часа 49 минут
еще одного не могу понять, зачем здесь использовать многоступенчатые массивы?
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
BasicMan
Эксперт
29316 / 5623 / 2384
Регистрация: 17.02.2009
Сообщений: 30,364
Блог
04.04.2012, 12:37
Помогаю со студенческими работами здесь

Интерактивная программа, исправить код
посмотрите что не правильно. 10 CLS 20 LOCATE 5, 30: PRINT &quot;hello my name vova,a kak zovyt teba?&quot; 30 INPUT n$ 40 PRINT ...

Программа шифрования: исправить код
Модуль Option Explicit ' ....----==== API Declarations ====----.... Private Declare Function CryptAcquireContext Lib...

Программа на fasm, исправить код
Вот программа: use16 org 100h mov al, d8 sub ah, ah dec ah mov d16, ax(вот здесь ошибку выдает) mov ax, 4c00h int 21h

Программа для тестирования: исправить код
Проект тестирования,режим экзамена Ошибки:После постбэка ,галочки checkbox остаются на выбранных ответах. using System; using...

Программа крестики-нолики, исправить код
Написать программу крестики-нолики. Создана программа, но может чего-то пропустил. Не правильно работает программа. Версия у меня 2003...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
5
Ответ Создать тему
Новые блоги и статьи
SDL3 для Web (WebAssembly): Реализация движения на Box2D v3 - трение и коллизии с повёрнутыми стенами
8Observer8 20.02.2026
Содержание блога Box2D позволяет легко создать главного героя, который не проходит сквозь стены и перемещается с заданным трением о препятствия, которые можно располагать под углом, как верхнее. . .
Конвертировать закладки radiotray-ng в m3u-плейлист
damix 19.02.2026
Это можно сделать скриптом для PowerShell. Использование . \СonvertRadiotrayToM3U. ps1 <path_to_bookmarks. json> Рядом с файлом bookmarks. json появится файл bookmarks. m3u с результатом. # Check if. . .
Семь CDC на одном интерфейсе: 5 U[S]ARTов, 1 CAN и 1 SSI
Eddy_Em 18.02.2026
Постепенно допиливаю свою "многоинтерфейсную плату". Выглядит вот так: https:/ / www. cyberforum. ru/ blog_attachment. php?attachmentid=11617&stc=1&d=1771445347 Основана на STM32F303RBT6. На борту пять. . .
Камера Toupcam IUA500KMA
Eddy_Em 12.02.2026
Т. к. у всяких "хикроботов" слишком уж мелкий пиксель, для подсмотра в ESPriF они вообще плохо годятся: уже 14 величину можно рассмотреть еле-еле лишь на экспозициях под 3 секунды (а то и больше),. . .
И ясному Солнцу
zbw 12.02.2026
И ясному Солнцу, и светлой Луне. В мире покоя нет и люди не могут жить в тишине. А жить им немного лет.
«Знание-Сила»
zbw 12.02.2026
«Знание-Сила» «Время-Деньги» «Деньги -Пуля»
SDL3 для Web (WebAssembly): Подключение Box2D v3, физика и отрисовка коллайдеров
8Observer8 12.02.2026
Содержание блога Box2D - это библиотека для 2D физики для анимаций и игр. С её помощью можно определять были ли коллизии между конкретными объектами и вызывать обработчики событий столкновения. . . .
SDL3 для Web (WebAssembly): Загрузка PNG с прозрачным фоном с помощью SDL_LoadPNG (без SDL3_image)
8Observer8 11.02.2026
Содержание блога Библиотека SDL3 содержит встроенные инструменты для базовой работы с изображениями - без использования библиотеки SDL3_image. Пошагово создадим проект для загрузки изображения. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru