Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › C# Coding/Loops - Assignment help.
New Posts  All Forums:Forum Nav:

C# Coding/Loops - Assignment help.

post #1 of 3
Thread Starter 
Hi guys,

I am doing work for an assignment and I am really struggling to write the code, I understand it when its there for me but when it comes down to writing it I seem to forget what I am meant to be doing frown.gif

I have 3 questions and I have completed the first one but I wanted too double check that it's right.
Question 1:

write a program to input 3 integers sum the numbers and output the sum .

Question 2:

A Computer retailer offers 2 packages
Deluxe costs = $1500
Super costs $1700
Customer can purchase extra hdd cap Attribute 0.50 per gig;
Program required to input the computer package type ( "D" deluxe "S" super) and input the amount of extra hdd cap as a whole number display total cost. as super pc with extra 100gb hdd would cost 1700+100*0.50 = 1750.

Question 3:
Input number of subject students are enrolled in and validate that the number is greater than 0. use as loop for validation only once Number is entered does the Program continue to calculate student fee. each subject costs 100. calculate the student fee by
by multiplying Number of subject by $100,
output the number of subjects and students fee.

Thanks in advanced, and +rep for best answer.
post #2 of 3
Because this is an assignment, I can only give you pseudo-code of program flow. Its up to you to understand and translate it to C#.

Question 1
Code:
let x: 0 /* the sum is stored here */
let n: 0 /* the current input is stored here */

/* loop three times */
for count 1 to 3
        n: get_input /* pseudo-function gets input from the user */
        x: ( x + n ) /* set x (our sum) to itself plus the current input */
end

print x /* write it out to the screen */

Question 2 - no loops required for this one.
Code:
/* declare our constants */
let constant deluxe_base: 1500
let constant super_base: 1700
let constant per_gigabyte: 0.5

let x: 0 /* we'll store the total cost here */
let package: get_input /* pseudo-function gets input from the user. this time we get the type (D or S) */
let extra: get_input /* pseudo-function gets input from the user. this time we get the additional GB */ 

if package is "D"
        x: ( deluxe_base + ( extra * per_gigabyte ) ) /* set our cost to be the base price of deluxe, plus any extra GB multiplied by cost per extra GB */
else if package is "S"
        x: ( super_base + ( extra * per_gigabyte ) ) /* set our cost to be the base price of super, plus any extra GB multiplied by cost per extra GB */
end

print ceil(x) /* round x to the nearest whole number and output it to the screen */

Question 3
Code:
/* declare our constants */
let constant subject_price: 100

let x: 0 /* we'll store the student fee here */
let n: 0 /* initialize number of subjects variable */

/* use a do-while loop to continue until the user enters a number greater than zero */
do
        n: get_input /* pseudo-function gets input from the user */
while n is 0 or less

/* once we get here, we can do the calculation */
x: n * subject_price /* calculate the price by multiplying the number of subjects by the subject price  */

/* output the number of subjects entered, and the student fee */
print "Number of subjects: {n}" 
print "Student fee: {x}"
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
Ol' Sandy
(28 items)
 
"Zeus"
(12 items)
 
Elite Preview
(6 items)
 
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230v3 Gigabyte GA-Z97X-UD5H-BK MSI Gaming GTX 980 Kingston 32GB (4x8) 
Hard DriveHard DriveHard DriveHard Drive
Plextor PX-256M5S 256GB Samsung EVO 1TB Hitachi HDS721010CLA332 Hitachi HDS723020BLA642 
Hard DriveHard DriveHard DriveOptical Drive
Hitachi HDS723020BLA642 Hitachi HUA722010CLA330 WDC WD10EARS-00Z5B1 TSSTcorp CDDVDW SH-S223B 
CoolingCoolingOSMonitor
Phanteks PH-TC14PE with TY-140's Lamptron FCv5 (x2) Windows 8 Pro 64-bit Dell U2412M 
MonitorMonitorMonitorKeyboard
Dell U2412M Dell U2212HM Dell U2713HM Topre Realforce 87UB | Ducky DK9087 G2 Pro 
PowerCaseMouseMouse Pad
Corsair AX-750 Corsair Obsidian 650D Logitech G700 XTRAC Ripper XXL 
AudioAudioAudioAudio
Beyerdynamic DT-770 Pro 250ohm Schiit Bifrost DAC Schiit Asgard 2 HiVi Swan M50W 2.1 
CPUMotherboardRAMHard Drive
Intel Xeon E5-2620 Super Micro X9SRL-F-B 128GB 1333MHz LSI 9271-8i 
OSPowerCase
VMware ESXi 5.5 SeaSonic SS-400FL2 Fractal Define R3 
CPUMotherboardGraphicsRAM
Intel Core i5-3437U HP EliteBook Folio 9470m  Intel HD Graphics 4000  16GB DDR3 SDRAM 
Hard DriveOS
256GB SSD Windows 10 Insider Preview 
  hide details  
Reply
post #3 of 3
@OP tompsonn has pretty much summed up everything you need to do, it should be enough for you to convert it into actual code.
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › C# Coding/Loops - Assignment help.