Contents
- admissions3.py
- admissions.c
- Admissions.class
- admissions.cpp
- Admissions.java
- admissions.py
- a.out
- createPrintableLab.sh
- twod_exercises.py
admissions3.py 1/9
[top][prev][next]
"""
Saint Bonaventure University Programming Contest
Problem #1 - Getting Into College
SOLUTION
"""
def main():
criteria = input()
criteriaList = criteria.split()
ap = int(criteriaList[0])
intangibles = int(criteriaList[1])
gpa = int(criteriaList[2])
sat = int(criteriaList[3])
score = ap*10 + intangibles*8 + gpa*0.25 + sat*0.01
if score >= 70:
print("ADMIT")
else:
print("DENY")
main()
admissions.c 2/9
[top][prev][next]
#include<stdio.h>
/*
* Saint Bonaventure University Programming Contest
* Problem #1 - Getting Into College
*
* SOLUTION
*
* To compile: gcc -o admissions admissions.c
*/
int main() {
int ap, intangibles, gpa, sat;
double score;
scanf("%d%d%d%d", &ap, &intangibles, &gpa, &sat);
score = ap*10 + intangibles*8 + gpa*0.25 + sat*0.01;
if (score >= 70) {
printf("ADMIT\n");
}
else {
printf("DENY\n");
}
}
Admissions.class 3/9
[top][prev][next]
Êþº¾ 2 6
!
"?Ð ?„záG®{@Q€ # $
% & ' ( ) <init> ()V Code LineNumberTable main ([Ljava/lang/String;)V
StackMapTable *
SourceFile Admissions.java java/util/Scanner + , - . / 0 1 2 ADMIT 3 4 5 DENY
Admissions java/lang/Object [Ljava/lang/String; java/lang/System in Ljava/io/InputStream; (Ljava/io/InputStream;)V nextInt ()I out Ljava/io/PrintStream; java/io/PrintStream println (Ljava/lang/String;)V ! *· ±
± Z» Y² · L+¶ =+¶ >+¶ 6+¶ 6
hh`‡‡ kc‡ kc9
—› ²
¶ § ² ¶ ± *
! = F Q Y ÿ Q
admissions.cpp 4/9
[top][prev][next]
// Saint Bonaventure University Programming Contest
// March 2, 2007
// Problem #1 - Getting Into College
// Team Name: SOLUTION
// To compile: g++ -o admissionscpp admissions.cpp
#include <iostream>
using namespace std;
int main() {
int AP, intangibles, GPA, SAT;
cin >> AP >> intangibles >> GPA >> SAT;
double score = AP*10 + intangibles*8 + GPA*0.25 + SAT*0.01;
if (score >= 70)
cout << "ADMIT" << endl;
else
cout << "DENY" << endl;
char xyzzy;
cin >> xyzzy;
return 0;
}
Admissions.java 5/9
[top][prev][next]
import java.util.Scanner;
/**
* Saint Bonaventure University Programming Contest
* Problem #1 - Getting Into College
*
* To compile: javac Admissions.java
*
* @author SOLUTION
* @version March 2, 2007
*/
public class Admissions {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int AP = sc.nextInt();
int intangibles = sc.nextInt();
int GPA = sc.nextInt();
int SAT = sc.nextInt();
double score = AP*10 + intangibles*8 + GPA*0.25 + SAT*0.01;
if (score >= 70) {
System.out.println("ADMIT");
}
else {
System.out.println("DENY");
}
}
}
admissions.py 6/9
[top][prev][next]
"""
Saint Bonaventure University Programming Contest
Problem #1 - Getting Into College
SOLUTION
"""
def main():
criteria = raw_input()
criteriaList = criteria.split()
ap = int(criteriaList[0])
intangibles = int(criteriaList[1])
gpa = int(criteriaList[2])
sat = int(criteriaList[3])
score = ap*10 + intangibles*8 + gpa*0.25 + sat*0.01
if score >= 70:
print "ADMIT"
else:
print "DENY"
main()
a.out 7/9
[top][prev][next]
createPrintableLab.sh 8/9
[top][prev][next]
# Script to print the students' code neatly
# by Sara Sprenkle, 09.2007
# Updated 01.2017 to just use the name of the assignment.
# Updated 01.2019 to prevent including the old .ps and .out files
# Updated 01.2021 to be able to be run from any directory and
# to create .pdf file and not include .pdf files
ARGS=1 # Number of arguments expected.
E_BADARGS=65 # Exit value if incorrect number of args passed.
test $# -lt $ARGS && echo "Usage: `basename $0` <labdirname>" && exit $E_BADARGS
COURSE=cs111
LABDIR=$1
PATHTOLAB=$HOME/$COURSE/$LABDIR
OUTDIR=$HOME/$COURSE
if [ ! -e $PATHTOLAB ];
then
echo "Directory $PATHTOLAB does not exist"
echo " Check that you're using the correct name."
exit
fi
if [ -f $PATHTOLAB ];
then
echo "ERROR: entered argument ($LABDIR) must be a directory"
exit
fi
base=`basename $LABDIR`
if [ -e $PATHTOLAB/$base.out ] || [ -e $PATHTOLAB/*.ps ] || [ -e $PATHTOLAB/*.pdf ];
then
echo "ERROR: You previously executed this program from"
echo "your assignment directory ($base) instead of the cs111 directory."
echo
echo "Remove $base.out, $base.ps, and $base.pdf from your $base directory and try again."
exit
fi
OUTPUT=$OUTDIR/$base.out
if [ -e $OUTPUT ];
then
rm $OUTPUT
fi
for FILE in `ls $PATHTOLAB/`
do
if [ -f $PATHTOLAB/"$FILE" ];
then
echo "Printing $FILE"
echo -----------------------"$FILE"-------------------- >> $OUTPUT
cat $PATHTOLAB/"$FILE" >> $OUTPUT
fi
done
if [ -e $OUTPUT ];
then
echo "CREATING FILE: $OUTDIR/$base.ps"
enscript -2r -Epython --word-wrap --mark-wrapped-lines=box $OUTDIR/$base.out -o $OUTDIR/$base.ps
echo "CREATING PDF: $OUTDIR/$base.pdf"
ps2pdf $OUTDIR/$base.ps $OUTDIR/$base.pdf
else
echo "ERROR: $OUTDIR/$base.out does not exist; could not create ps file"
fi
twod_exercises.py 9/9
[top][prev][next]
# Practice with 2D Lists
# Sara Sprenkle
def main():
#rows = int(input("How many rows? "))
#columns = int(input("How many columns? "))
rows = 3
columns = 4
print()
print("Correct Matrix Creation:")
print('-'*30)
matrix = create2DList(rows, columns)
print(matrix)
print("\nAssigning matrix[1][2]=3")
matrix[1][2] = 3
print("Result: ")
print(matrix)
print()
print("*"*55)
print("Incorrect Matrix Creation:")
print('-'*30)
matrix = noCreate2DList(rows, columns)
print(matrix)
print("\nAssigning matrix[1][2]=3")
print("Result: ")
matrix[1][2] = 3
print(matrix)
def create2DList(rows, cols):
"""Returns a two-dimensional list filled with 0s that is 'rows' tall and
'cols' wide."""
twodlist = []
for rowPos in range(rows):
# creates a new list
row = []
for colPos in range(cols):
row.append(0)
twodlist.append(row)
return twodlist
def noCreate2DList(rows, cols):
"""Does not create a 2D list because each 'row' points to the same list in
memory."""
twodlist = []
# creates one list
onerow = []
for colPos in range(cols):
onerow.append(0)
for rowPos in range(rows):
twodlist.append(onerow)
return twodlist
main()
Generated by GNU Enscript 1.6.6.