Jump to content

VAP810

Member
  • Posts

    5
  • Joined

  • Last visited

Awards

This user doesn't have any awards

VAP810's Achievements

  1. VAP810

    Question

    In the assignment about Computer System architecture i saw this : "Show how to store the decimal negative number -35 using the two’s complement method." Now i know how to explain the number to binary using that method,but i don't know how to store it. Can anyone help me ?
  2. in this assignment i have to make an app to store list of students, its information : - sId: The student ID of the form like GTxxxxx or GCxxxxx (x: is a digit) - sName: Student name - sDoB: Student date of birth - sEmail: Student email - sPhone: Student phone number - sAddress: Student address This application will need to provide following functionalities via a menu ======================= 1. Add new student 2. View all students 3. Search students 4. Delete students 5. Update student 6. Exit ======================= Please choose: When user chooses 1, program will prompt user to input student’s information (specified previously). After that, program will validate the input data and if they are all valid, program will add a new student to the current list of students. Program should inform to the user corresponding messages. When user chooses 2, the program will list all the students to the screen, each student in a row and student’s data fields are separated by ‘|’. When user chooses 3, the program will ask user to input student’s name to search for, the user can just type part of the name in order to search for complete student information. When user chooses 4, program will ask user to input student id to delete the student with the specified id if it exists, otherwise, it will display a message to inform users that the student with such id doesn’t exist. When user chooses 5, program will first ask user to input student id to update, once inserted and a student with the inserted id exists, it will display current data for each field of the student and user can type in new data to update or just press enter to keep the current data for the field. When user chooses 6, program will exit. So here is my code /* ============================================================================ Name : jj.c Author : Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <malloc.h> #include <string.h> int i=0; void menu(){ system("cls"); printf("=======================\n"); printf("1.Add new student\n"); printf("2.View all students\n"); printf("3.Search students\n"); printf("4.Delete students\n"); printf("5.Update student\n"); printf("6.Exit\n"); printf("=======================\n"); printf("Please select:"); int mn; while(1){ scanf("%d",&mn); system("cls"); if (mn ==1) addstudent(); else if(mn == 2) studentlist(); else if(mn == 3) searchstudent(); else if(mn == 4) deletestudent(); else if(mn == 5) updatestudent(); else if(mn == 6) exit(0); menu();} } typedef struct student{ char sname[40]; char sid[8]; char semail[20]; char sphone[12]; char sdob[11]; char saddress[50]; }student; student stlist[1000]; int n; void ignoreEnter() { char rmEnter[2]; gets(rmEnter); } void readgetid(){ int length; while (1) { gets(stlist[i].sid); length = strlen(stlist[i].sid); if (length !=7) printf("The id length is wrong, please input id again:"); else {printf("id length correct\n"); } int result1,result2,result3; result1 = strncmp(stlist[i].sid, "GC", 2); result2 = strncmp(stlist[i].sid, "GT", 2); int l = 2; do { result3 = isdigit(stlist[i].sid[l]); l++; if (result3 == 0) break; } while(l<strlen(stlist[i].sid)); if ((result1 == 0) || (result2 == 0)) { printf("The first 2 letters are true\n"); if (result3 != 0) { printf("id is correct\n"); break; } else printf("The remaining letters are wrong, please enter the id again(the remain letters must be digit): "); } else printf("The first 2 letters are wrong, please enter id again(the letters must be GC or GT): "); } } void addstudent(student *stlist) { char count; do { printf("Enter information of students:\n"); printf("Enter student id:"); fflush(stdin); readgetid(); gets(stlist[1000].sid); printf("Enter name: "); gets(stlist[1000].sname); printf("Enter date of birth: "); gets(stlist[1000].sdob); printf("Enter email:"); gets(stlist[1000].semail); printf("Enter phone number:"); gets(stlist[1000].sphone); printf("Enter address:"); gets(stlist[1000].saddress); n++; printf("Do you want to continue input student? y/n\n"); char c; scanf("%c", &c); ignoreEnter(); if(c == 'n') break; } while(1); } void printstudent() { printf("=============================\n"); printf("Student id: "); puts(stlist[1000].sid); printf("Student name: "); puts(stlist[1000].sname); printf("Student date of birth: "); puts(stlist[i].sdob); printf("Student email: "); puts(stlist[1000].semail); printf("Student phone: "); puts(stlist[1000].sphone); printf("Student address: "); puts(stlist[1000].saddress); printf("=============================\n"); } void studentlist() { int i; for(i = 0; i < n; i++) printstudent(1000); getch(); } void searchstudent() { studentlist(); system("cls"); char search[20]; int i; printf("Enter student name : "); fflush(stdin); gets(search); printf("Students which have the name %s is: \n",search); for(i = 0; i < n; i++) if(strstr(stlist[1000].sname, search)) printstudent(1000); printf("\n\n"); getch(); } void deletestudent() { system("cls"); printf("Student id: "); char sid[7]; gets(sid); int i, k; for(i = 0; i < n; i++) if(strcmp(sid, stlist[1000].sid) == 0) { for(k = i + 1; k < n; k++) stlist[k - 1] = stlist[k]; n--; i--; getch(); } else{ printf("The student with such id doesn’t exist"); getch(); } } void updatestudent() { system("cls"); printf("Student id: "); char sid[7]; gets(sid); int i; for(i = 0; i < n; i++) if(strcmp(sid, stlist[1000].sid) == 0) { addstudent(&stlist[1000]); break; } getch(); } int main(void){ menu(); } the "Add new student" part when i input the data it responding the information but the output view all student part didnt save it. So the "delete student" and the "update student" part dont work. Do you guys have any changes to make it work, i will appreciate if you guys make any changes to correct my code. Thanks
  3. Not bad, but i'm still wondering about its power,cause we're talking about graphics program here.
  4. Srry guys i forgot about the budget. He said that the budget is around 1000-1500$.
  5. I really need your help or any suggestion to build this system. Thx alot! ABC is a company planning to open a small branch in London, the aim of the company is to train professionals in graphic design and video editing, the company planning to run courses for the following software: Adobe Photoshop CC 2014 Adobe Premiere Pro CC (2014) PaintShop Pro X7 Ultimate The company approached you as computer expert and asked for help in designing and creating the specification of the 20 computers for the class room.
×