Computer Science Problem C++


cla5a.cpp
1 // cla10a BY student name, CSCI 2170-section
2 //File: cla10a.cpp
3 //Author: Dr. Roland H. Untch
4 //Purpose: This program displays a student's classification
5 // (e.g., "freshman", "sophmore", etc.) based on an
6 // integer classification code that is read in. In
7 // it's current form, this program uses nested IF
8 // statements to encode a "multiway branch" or "case
9 // construct" to determine the student's classification.
10 // As part of an exercise, the IF statements should
11 // be completely replaced by a SWITCH statement; that
12 // is, afterwards no IF statements will exist in the
13 // modified code. The encoding scheme is:
14 // 1 2 3 4 5 6
15 // freshman sophomore junior senior graduate graduate
16
17 //include files...
18 #include <iostream>
19
20 using namespace std;
21
22
23 int main()
24 {
25 int classification; //classification of a student
26
27 // input student's information
28 cout << "Enter the student's classification code number (1-6): ";
29 cin >> classification;
30
31 cout << "Your classification is " ;
32 // Check for a valid classification and proceed accordingly
33 if (classification >= 1 && classification <= 6)
34 {
35 //display appropriate classification phrase
36 if ( classification==1)
37 cout << "freshman";
38 else if (classification==2)
39 cout << "sophomore";
40 else if (classification==3)
41 cout << "junior";
42 else if (classification==4)
43 cout << "senior";
44 else
45 cout << "graduate";
46 cout << "." << endl;
47 }
48 else
49 cout << "unknown. Invalid classification code." <<endl;
50
51 return 0;
52 }UPDATED C++ PROGRAM WITH SWITCH - CASE
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile
and execute it.
*******************************************************************************/
// cla10a BY student name, CSCI 2170-section
//File: cla10a.cpp
//Author: Dr. Roland H. Untch
//Purpose: This program displays a student's classification
// (e.g., "freshman", "sophmore", etc.) based on an
// integer classification code that is read in. In
// it's current form, this program uses nested IF
// statements to encode a "multiway branch" or "case
// construct" to determine the student's classification.
// As part of an exercise, the IF statements should
// be completely replaced by a SWITCH statement; that
// is, afterwards no IF statements will exist in the
// modified code. The encoding scheme is:
// 1 2 3 4 5 6
// freshman sophomore junior senior graduate graduate
//include files...
#include <iostream>
using namespace std;
int main()
{
int classification; //classification of student
// input student's information
cout << "Enter the student's classification code number
(1-6): ";
cin >> classification;
cout << "Your classification is " ;
//swtch-case statementt startshere
switch(classification){
case 1: cout<<"freshman.";
break;
case 2: cout<<"sophomore.";
break;
case 3: cout<<"junior.";
break;
case 4: cout<<"senior.";
break;
//case 5 and 6 both will be taken care in case 6 block
case 5:
case 6: cout<<"graduate.";
break;
default: //for all other cases apart from 1-6
cout << "unknown. Invalid classification code.";
}
cout<<endl;
return 0;
}
===================================
OUTPUT
===================================
Run1
Enter the student's classification code number (1-6): 4
Your classification is senior.
Run2
Enter the student's classification code number (1-6): 5
Your classification is graduate.
Run3
Enter the student's classification code number (1-6): 9
Your classification is unknown. Invalid classification code.
Computer Science Problem C++ cla5a.cpp 1 // cla10a BY student name, CSCI 2170-section 2 //File: cla10a.cpp...
PART I: Create an abstract Java class named “Student” in a package named “STUDENTS”. This class has 4 attributes: (1) student ID: protected, an integer of 10 digits (2) student name: protected (3) student group code: protected, an integer (1 for undergraduates, 2 for graduate students) (4) student major: protected (e.g.: Business, Computer Sciences, Engineering) Class Student declaration provides a default constructor, get-methods and set-methods for the attributes, a public abstract method (displayStudentData()). PART II: Create a Java class named...
please help
Write a simple program with Student class having STL list of Record's structure as a member. 1. Records of the Students are not accessible to the outside world. 2. Student shall output its standing (Freshman, Sophomore etc). 3. A Student can only be created with the name 4. A class can only be added if there is a class name and the passing grade. Driver program creates a Student, adds few classes to the Student's records, then prints...
,,1. Which of the following statments are valid C++ statements? A) cout << "Hello World" : B) cout << Hello World; C) cout << "Hello " << "World" ; D) cout << "Hello" << "World" ; 2. What is the difference between the literals 'A' and "A"? ,3. Read the input from user; Check for valid entries If input is invalid: print an error message; else: calculate the result and print to the console; exit; The code snippet above may...
may i ask for help with this c++ problem?
this is the code i have for assignment 4 question 2:
#include<iostream>
#include<string>
#include<sstream>
#include<stack>
using namespace std;
int main()
{
string inputStr;
stack <int> numberStack;
cout<<"Enter your expression::";
getline(cin,inputStr);
int len=inputStr.length();
stringstream inputStream(inputStr);
string word;
int val,num1,num2;
while (inputStream >> word)
{
//cout << word << endl;
if(word[0] != '+'&& word[0] != '-' && word[0] !=
'*')
{
val=stoi(word);
numberStack.push(val);
// cout<<"Val:"<<val<<endl;
}
else if(word[0]=='+')
{
num1=numberStack.top();
numberStack.pop();
num2=numberStack.top();
numberStack.pop();...
CSCI 2010 Lab11 Link-Lists
Lab 11A Linked-Lists
Preparation
Create a Visual Studio C++ Project C2010Lab11A
Add the following to the project.
//LinkedList.cpp
#include <cstdlib>
#include "LinkedList.h"
using namespace std;
//---------------------------------------------------
//List Element Members
//---------------------------------------------------
ListElement::ListElement(int d, ListElement * n)
{
datum=d;
next=n;
}
int ListElement::getDatum () const
{
return datum;
}
ListElement const* ListElement::getNext () const
{
return next;
}
//---------------------------------------------------
//LinkedList Members
//---------------------------------------------------
LinkedList::LinkedList ()
{
head=NULL;
}
void LinkedList::insertItem(int item)
{
ListElement *currPtr = head;
ListElement *prevPtr =...
Set-Up · Create a new project in your Eclipse workspace named: Lab13 · In the src folder, create a package named: edu.ilstu · Import the following files from T:\it168\Labs\lab13. Note that the .txt file must be in the top level of your project, not inside your src folder. o Student.java o StudentList.java o students.txt Carefully examine the Student.java and StudentList.java files. You are going to complete the StudentList class (updating all necessary Javadoc comments), following the instruction in the code....
// This program displays a menu and asks the user to make a 2 // selection. An if/else if statement determines which item 3 // the user has chosen. 4 #include <iostream> 5 #include <iomanip> 6 using namespace std; 7 8 int main() 9 { 10 int choice; // To hold a menu choice 11 int months; // To hold the number of months 12 double charges; // To hold the monthly charges 13 14 // Constants for membership rates...
so i have my c++ code and ive been working on this for hours
but i cant get it to run im not allowed to use arrays. im not sure
how to fix it thank you for the help
our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses...
C++ Homework Help:
The text file that it wants you to download is this:
Name: Peter Parker
CSCI-261: 95
CSCI-262: 90.625
CSCI-442: 91.20
Name: Mary Smith
CSCI-442: 65.0
CSCI-562: 79.1234
CSCI-580: 70.24
Name: Pat Brown
CSCI-562: 95
CSCI-565: 88.0
CSCI-580: 91.20
Name: Linda Williams
CSCI-262: 65.0
CSCI-306: 67.719
CSCI-562: 70.200
Name: John Miller
CSCI-261: 95.281
CSCI-306: 90.625
CSCI-565: 91.20
Name: Patricia Johnson
CSCI-306: 65.012
CSCI-442: 84.76
CSCI-580: 70
Name: Brian Hall
CSCI-261: 65.0
CSCI-306: 84.712
CSCI-442: 75.24
Name: Sandra Nelson...
Last picture is the tester program!
In this Assignment, you will create a Student class and a Faculty class, and assign them as subclasses of the superclass UHPerson. The details of these classes are in the UML diagram below: UHPerson - name : String - id : int + setName(String) : void + getName(): String + setID(int) : void + getID(): int + toString(): String Faculty Student - facultyList : ArrayList<Faculty - rank: String -office Hours : String - studentList...